问题描述:

protected void Button1_Click(object sender, EventArgs e)

{

// C# code for SQL connection

}

<input id="Button2" type="button" value="Pakistan" onclick ="Button1_Click()" />

网友答案:

OK there is one solution if you insist on using the Input type Button instead of using the normal Asp:Button

<input id="Button2" type="button" value="Pakistan" onclick ="button2();"/>

<script>
function button2()
{
   __doPostBack('Button2', 'postback')
}

</script>

now in your page load in C# code behind file:

protected void Page_Load(Object sender,EventArgs e) {

if (Request["__EVENTTARGET"]=="Button2")
{
//call the Code for Sql Connection

}


}

regards

相关阅读:
Top