using System.Web.UI.WebControls; namespace JavaScriptCallServerEvent {public partial class Default : System." />
您好,欢迎来到[编程问答]网站首页   源码下载   电子书籍   软件下载   专题
当前位置:首页 >> 编程问答 >> .NET >> DropDownList的SelectedIndexChanged事件,由JS提交执行。怎么做?

DropDownList的SelectedIndexChanged事件,由JS提交执行。怎么做?

来源:网络整理     时间:2016/6/25 20:05:15     关键词:

关于网友提出的“ DropDownList的SelectedIndexChanged事件,由JS提交执行。怎么做?”问题疑问,本网通过在网上对“ DropDownList的SelectedIndexChanged事件,由JS提交执行。怎么做?”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:

问题: DropDownList的SelectedIndexChanged事件,由JS提交执行。怎么做?
描述:

using System.Web.UI.WebControls; namespace JavaScriptCallServerEvent {     public partial class Default : System.Web.UI.Page     {         public string CS;         protected void Page_Load(object sender, EventArgs e)
/>         {             ClientScriptManager csm = this.ClientScript;
            CS = csm.GetPostBackEventReference(ddlList, null);             Response.Write(CS);             Response.End();
            if (!Page.IsPostBack)             {                 CS = csm.GetPostBackEventReference(ddlList, null);             }             else             {                 Response.Write("postback");             }         }         protected void ddlList_SelectedIndexChanged(object sender, EventArgs e)         {             Response.Write("A");             Response.Write((sender as DropDownList).SelectedValue);         }         protected void Button1_Click(object sender, EventArgs e)         {         }     } }


解决方案1:

引用 3 楼  的回复:
CS = csm.GetPostBackEventReference(ddlList, null); 我已经加了这个了。
你可以在页面上注册一个javascript函数(例如RegisterStartupScript输出函数),其函数体就是这个CS内容。然后,客户端只要调用这个函数就能让服务器端直接触发其SelectedIndexChanged事件了。解决方案2:

http://www.google.com.hk/search?hl=zh-CN&newwindow=1&safe=strict&sa=X&ei=e7DlT4ubGu6SiQfM1ehZ&ved=0CEkQvwUoAQ&q=ipostbackeventhandler+dropdownlist+getpostbackeventreference&spell=1&biw=1364&bih=707


以上介绍了“ DropDownList的SelectedIndexChanged事件,由JS提交执行。怎么做?”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:http://www.codes51.com/itwd/2066252.html

相关图片

相关文章