Asp.net视图状态不保存控件的样式 [英] Asp.net Viewstate not saving a control's style

查看:80
本文介绍了Asp.net视图状态不保存控件的样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已阅读,在asp.net中存储视图状态在回发的控件属性的值。
可以说,我有一个具有一个文本框的网页

I have read that the viewstate in asp.net stores the values of control properties across postbacks. Lets say I have a page that has a textbox

<asp:TextBox ID="fldFileId" runat="server"></asp:TextBox>

,然后通过JavaScript客户端,我得到的元素的引用,然后设置边框样式正是如此。

and then on the client side via javascript, I get a reference to the element , and then set the border style thusly

refToTextBox.style["border-style"] = "dashed";

一旦回传,边框风格dissapeared与文本恢复到原来的样子。但对于一个asp的属性一眼:在VS2010的TextBox有的一个边框属性它。
有没有为什么这个属性不被保存视图状态的一个原因?

Upon postback, the border style has dissapeared and the textbox reverts to its original look. But glancing at the properties for an asp:TextBox in VS2010 there is a 'BorderStyle' property for it. Is there a reason why this attribute does not get saved in the view state?

推荐答案

设置值的客户端不更新的ViewState。你必须设置样式服务器端的ViewState中存储它。或者,您可以:

Setting a value client-side does not update ViewState. You have to set the style server-side for ViewState to store it. Alternatively, you could:


  1. 回发后重新运行你的JavaScript。

  2. 店铺的造型在cookie中,并使用JavaScript来恢复风格。

  3. <击>查找JavaScript库修改的ViewState在客户端(不推荐)。

  1. Re-run your JavaScript after postback.
  2. Store the styling in a cookie and use JavaScript to restore the style.
  3. Find a JavaScript library to modify ViewState on the client-side (not recommended).

这篇关于Asp.net视图状态不保存控件的样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆