我做了一个测试应用程序,其中控件是html5控件.我有2个文本框和一个html5按钮.我想在html5按钮上触发onclick事件,并且通过onclick事件调用的方法在服务器端.
我试过但它没有工作.任何人都可以帮我从html5按钮调用服务器端方法.我发布了我的代码.
//clientside code
<form id="form1" runat="server">
<div>
First name:<input type="search" name="searchfield" placeholder="enter your name"
autofocus="on" required="required" pattern="[A-z]" />
E-mail:
<input type="email" name="emailfield" placeholder="enter emailid" />
<button onclick="btnSave_click" value="Click to Save" id="btnSave" runat="server" autofocus="autofocus" formtarget="_parent">
Click to Save</button>
</div>
</form>
// server side code
protected void btnSave_Click(object sender, EventArgs e)
{
string name = Request.Form["searchfield"];
string emailid = Request.Form["emailfield"];
string dob = Request.Form["bday"];
SqlConnection cn = new SqlConnection();
cn.ConnectionString = "Data Source=CP1106\\SQLEXPRESS;Initial Catalog=Testdb;User ID=sa;Password=pwd";
cn.Open();
string query = "INSERT INTO …Run Code Online (Sandbox Code Playgroud) 我想将此字符串"Mon,01 Apr 2013 10:00:00 GMT"转换为sql server 2008中的datetime但由于GMT我无法转换它