<select id="dress" onserverchange="dress_ServerChange" name="dress" runat="server"></select>
----------------------------------------------------
.aspx.cs
public void dress_ServerChange(object sender, System.EventArgs e)
{
Response.Write("11111111");
}
调试运行都通过了,没有错误 就是在触发select的时候不执行 dress_ServerChange,不知道为什么请高手指点!谢谢
becauset __doPostBack is not generated, try the following or remove if (!IsPostBack):
<form runat="server">
<select id="dress" onserverchange="dress_ServerChange" name="dress" runat="server">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<asp:Button id="btn" runat="server" Text="Refresh" />
</form>
<script language="C#" runat="server">
void Page_Load(object sender, System.EventArgs e)
{
string s = Page.GetPostBackEventReference(dress);
if (!IsPostBack)
dress.Attributes.Add("onchange",s);
}
public void dress_ServerChange(object sender, System.EventArgs e)
{
Response.Write("ServerChange is called at " +DateTime.Now + "<BR>");
Response.Write(dress.SelectedIndex);
}
</script>
http://topic.csdn.net/t/20050823/03/4224660.html
----------------------------------------------------
.aspx.cs
public void dress_ServerChange(object sender, System.EventArgs e)
{
Response.Write("11111111");
}
调试运行都通过了,没有错误 就是在触发select的时候不执行 dress_ServerChange,不知道为什么请高手指点!谢谢
becauset __doPostBack is not generated, try the following or remove if (!IsPostBack):
<form runat="server">
<select id="dress" onserverchange="dress_ServerChange" name="dress" runat="server">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<asp:Button id="btn" runat="server" Text="Refresh" />
</form>
<script language="C#" runat="server">
void Page_Load(object sender, System.EventArgs e)
{
string s = Page.GetPostBackEventReference(dress);
if (!IsPostBack)
dress.Attributes.Add("onchange",s);
}
public void dress_ServerChange(object sender, System.EventArgs e)
{
Response.Write("ServerChange is called at " +DateTime.Now + "<BR>");
Response.Write(dress.SelectedIndex);
}
</script>
http://topic.csdn.net/t/20050823/03/4224660.html