Call Server Side event from HTML Button click

Last Reply 3 months ago By dharmendr

Posted 3 months ago

search button is not getting fired

 

<input class="dt-header-search-submit dt-button dt-button-danger" type="button" value="Search" style="top:1px;width:225px;" runat="server" onserverclick="doit">

i have used the breakpont but after clicking on search,its not getting fired.

code behind:

 

 protected void doit(object sender, EventArgs e)
    {
        txtkeyword.Value = "";
    }

 

You are viewing reply posted by: dharmendr 3 months ago.
Posted 3 months ago

Hi chetan,

Your code is working.

Refer below sample.

HTML

<asp:TextBox runat="server" ID="txtName" />
<br />
<input class="dt-header-search-submit dt-button dt-button-danger" type="button"
    value="Search" style="top: 1px; width: 225px;" runat="server" onserverclick="doit" />

C#

protected void doit(object sender, EventArgs e)
{
    ClientScript.RegisterClientScriptBlock(this.GetType(), "", "alert('Name is : " + txtName.Text.Trim() + "')", true);
}

Screenshot