首页 > 其他分享 >After page postback, DropDownList item attributes "color" cleared ?

After page postback, DropDownList item attributes "color" cleared ?

时间:2023-11-10 15:00:56浏览次数:44  
标签:After End color List postback SelectedItems item ByVal Integer

DropDownList1.SelectedItem.Attributes.Add("style", "Color:GREEN")
This is set when a person clicks a button, "resubmit order"... then the selected item is turned green so they know they've already fixed that order item.
Now if I select a different item, the page posts back to grab new information for another order...., but the previously set dropdownlist item, is no longer green.
I'm not refilling the dropdown, if the postback=true, so I have no idea why the viewstate is not keeping the attributes of the dropdown list items.
How can I preserve the color of dropdownlist items, after a postback ?

----------------------

Try this:

Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As EventArgs)    
    For Each index As Integer In Me.SelectedItems    
        DropDownList1.Items(index).Attributes.Add("style", "Color:GREEN;background:red")    
    Next    
End Sub   
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)    
    'DropDownList1.SelectedItem.Attributes.Add("style", "Color:GREEN");    
    Dim selecteditems As List(Of Integer) = Me.SelectedItems    
    selecteditems.Add(DropDownList1.SelectedIndex)    
    Me.SelectedItems = selecteditems    
End Sub   
Private _SelectedItems As List(Of Integer)    
Public Property SelectedItems() As List(Of Integer)    
    Get    
        If ViewState("SelectedItems") IsNot Nothing Then    
            _SelectedItems = DirectCast(ViewState("SelectedItems"), List(Of Integer))    
        Else    
            _SelectedItems = New List(Of Integer)()    
        End If    
        Return _SelectedItems    
    End Get    
    Set(ByVal value As List(Of Integer))    
        ViewState("SelectedItems") = value    
    End Set    
End Property

http://forums.asp.net/p/1159612/1913450.aspx

http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_25339597.html



标签:After,End,color,List,postback,SelectedItems,item,ByVal,Integer
From: https://blog.51cto.com/emanlee/8299572

相关文章

  • XXII Open Cup named after E.V. Pankratiev, Grand Prix of Daejeon 部分题解
    省流:A、B、C、E、H、K、L。D和I之后可能会看心情补,剩下的题大概这辈子都不会做了。A.Points有两个由二维平面上的点组成的可重点集\(U,V\)。如下定义\(D(U,V)\):当\(U,V\)中存在一个为空时,\(D(U,V)=-1\)。否则\(D(U,V)=\min\limits_{(u_x,u_y)\inU,(v_x,v_y)......
  • Text家族又添新成员,TextBefore和​TextAfter提取指定符号前后内容!
    1职场实例小伙伴们大家好,今天我们来学习使用函数的方法提取指定符号前面或后面的内容。解决今天的这个问题,一般情况下我们可能会首先想到使用“分列”的方式提取,但是今天我们要求使用的是函数公式,所以不考虑这种束缚我们思维扩散的传统做法。要说运用公式,面对复杂的多函数嵌套,Excel......
  • 2023-11-02 微信小程序的button的border如何清除?==》清除其伪类after即可
    给微信小程序的button的border设置为0或者none,依旧无法清除,这是因为button的border是用了伪类after来实现的,清除该伪类即可,你也可以参考我的css:.button{padding:0;margin:0;background:transparent!important;&::after{border:0;}}......
  • D. Bracket Coloring
    D.BracketColoring题目大意:给你一组括号序列,要求你将涂颜色括号分类,相同颜色为一组,每组括号按他们出现的顺序可以构成一个漂亮序列如果满足以下条件之一,则括号序列称为优美序列:它是一个规则的括号序列;如果该序列中的字符顺序颠倒,它就会变成一个规则的括号序列。思路:首......
  • ae_After Efects下载-AE2023中文最新版下载 mac/win版
    aecs6软件中文版免费版同样保留有adobe的软件相互兼容性。它可以非常方便地调入photoshop,illustrator的层文件;premiere的的项目文件也可以近乎完美再现于AE中;甚至还可以调入Premiere的EDL文件。新版本还能将二维和三维在一个合成中灵活的混合起来。用户可在二维或者三维中工作或......
  • OpenTiny Vue 3.11.0 发布:增加富文本、ColorPicker等4个新组件,迎来了贡献者大爆发!
    你好,我是Kagol。非常高兴跟大家宣布,2023年10月24日,OpenTinyVue发布了v3.11.0......
  • RuntimeError: default_program(24): error: extra text after expected end of numbe
    详细报错Traceback(mostrecentcalllast):File"eval_roberta_qa.py",line24,in<module>output=model(input_ids,attention_mask,token_type_ids)File"/home/rzhang/miniconda3/envs/vamc/lib/python3.7/site-packages/torch/nn/mo......
  • CF1887E Good Colorings
    矩形的四个角颜色不同是个很难描述的条件,不妨利用行列二元关系转化,将\((x,y)\)颜色为\(c\)改为在\(x\)和\(y\)之间连接边权为\(c\)的边,则四角颜色不同就被我们转化为了,存在一个边权各不相同的四元环。此时把特殊条件【初始给定\(2n\)个格子\(2n\)个不同颜色】放在......
  • C. Colorful Table
    C.ColorfulTable设p1为最左边的a[p1]>=i,p2为最右边的a[p2]>=i,则i的面积大小为行的p1-p2,列的p1-p2,大小为2*(p2-p1+1)但是如果暴力的去求每个点的左右端点,肯定会超时,有没有办法优化呢?1.我们想到,大的数一定包含小的数:如果大的数算出来了,那么比他小的数一定也满足条件,可以递推2.......
  • 安装Image Color Summarizer
    安装网页网址: http://mkweb.bcgsc.ca/color-summarizer/?download在网址栏输入URL: http://mkweb.bcgsc.ca/color-summarizer/download/colorsummarizer-0.80-win.zip下载后如图 在搜索栏输入cmd调出命令管理器输入命令  -help会得到用法帮助bin\colorsummarize......