向页面拖一个Web控件<asp:Button ID="Button2" runat="server" Text="Button"/>在cs中: protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
Button2.Attributes["Text"] = "fgfgfg";
}
}运行之后,为什么Button2的文本没有变化呢?
{
if (!Page.IsPostBack)
{
Button2.Attributes["Text"] = "fgfgfg";
}
}运行之后,为什么Button2的文本没有变化呢?
解决方案 »
- 想做一个B/S架构的“即时通讯软件”,有两个技术难点不知道该如何解决,请高手帮助指点一下,谢谢了先!
- 在网上搞了个ip数据库,但不知道里面的字段怎样用换算得到的!望各位指教!谢谢
- .net中有关对象的问题?
- vb.net中,如何实现数据控件datalist的2层嵌套
- System.Web.UI.MobileControls.SelectionList控件
- ###求一sql语句
- 请问如何才能在执行Page_Load前保存Session?
- textarea或者texbox中输入连续的字母很多了,保存后再显示出来的话,会将table撑开?请问如何解决的?
- 一个网页视频的问题
- 请教各路高手!!!在线等回复
- 请问Page
- 设置验证码字体颜色
{
if (!Page.IsPostBack)
{
Button2.Attributes["value"] = "fgfgfg";
或者 Button2.text="dfd";
}
}
就算是改成Button2.Attributes["value"] = "fgfgfg";
也没对啊?是什么原因?
你的服务器Button2控件经asp.net处理后,会产生对应的html标签,
<input type="submit" name="Button2" value="Button" id="Button2" />
所以你应该Button2.Attributes["value"] = "fgfgfg";
Button2.Attributes["value"] = "fgfgfg";
后居然是 <input type="submit" name="Button1" value="Button" id="Button1" value="123" />
有两个value,而且显示的还是前者,等大神来回答了