How to make HtmlSelect Control with OnChange event to trigger C# code behind function

后端 未结 4 772
走了就别回头了
走了就别回头了 2021-01-14 06:30

How should I make \"Html Select Control\" with OnChange event to trigger C# code behind function
like ASP.NET SelectedIndexChanged of the DropDownList C

4条回答
  •  日久生厌
    2021-01-14 06:41

    I've found a great way to handle my problems, showing my ideas as following code

    Front End

      
    

    Back End

    protected void Page_Load(object sender, EventArgs e)
    {     
       ClientScriptManager cs = Page.ClientScript;
       this.StartDate.Attributes.Add("onchange", cs.GetPostBackEventReference(this.StartDate, this.StartDate.ID));
    }
    protected void StartDate_ServerChange(object sender, EventArgs e)
    {
    
    }
    

    PS: two references
    https://msdn.microsoft.com/en-us/library/ms153112(v=vs.110).aspx
    https://blog.csdn.net/lovegonghui/article/details/51942241

提交回复
热议问题