protected void Button1_Click(object sender, EventArgs e)
{
// C# code for SQL connection
}
<input id="Button2" type="button" value="Pakistan" onclick ="Button1_Click()" />
答案 0 :(得分:0)
如果您坚持使用输入类型按钮而不是使用普通的Asp:Button
,那么确定有一个解决方案<input id="Button2" type="button" value="Pakistan" onclick ="button2();"/>
<script>
function button2()
{
__doPostBack('Button2', 'postback')
}
</script>
现在在你的页面加载C#代码后面的文件:
protected void Page_Load(Object sender,EventArgs e) {
if (Request["__EVENTTARGET"]=="Button2")
{
//call the Code for Sql Connection
}
}
问候