开发者

Store controls' custom attributes in viewstate

I add "readonly" 开发者_JAVA百科attribute to ASP.NET controls in some event handlers.

control.Attributes.Add("readonly", "readonly");

But these attributes are not stored in viewstate and after postback these attributes are cleared. How can I make it stay after postback? Using control.ReadOnly = true; is not applicable because it makes control disabled and therefore ugly. Thank you everybody for help!


This is an example style applied to disabled input text...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<style type="text/css">
input[disabled]
{
    background-color:White; 
    border:0 solid #fff;
    color:red;
}
</style>

    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <input type="text" disabled="disabled" class="disabled"  value="i'm disabled!"/>
    </div>
    </form>
</body>
</html>

Tested on Google Chroome 13.0.782.112 on Windows 7.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜