这里有一些我的项目。我想添加评论表单,但在html形式,因为我已经使用服务器端另一个原因。 这是HTML代码:
<form id="modal_feedback" method="POST" action="#" accept-charset="UTF-8">
<p><label>Your Name<strong>*</strong><br>
<input runat="server" id="rvwname" type="text" autofocus required size="48" name="name" value=""></label></p>
<p><label>Email Address<strong></strong><br>
<input runat="server" id="rvwemail" type="email" title="Please enter a valid email address" size="48" name="email" value=""></label></p>
<p><label>Contact Number:*<br>
<input runat="server" id="rvwno" type="text" required size="48" name="contact" value=""></label></p>
<p><label>Message:<strong>*</strong><br>
<textarea runat="server" id="rvwmsg" required name="message" cols="48" rows="8"></textarea></label></p>
<p> <input runat="server" type="button" id="rvwsubmit" name="feedbackForm" value="Send" onserverclick="rvwsubmits" /> </p>
</form>
</div> <!-- #modal_window -->
</div> <!-- #modal_wrapper -->
和c#的后端代码是:
protected void rvwsubmits(object sender, EventArgs e)
{
string a = rvwname.Value;
string b = rvwno.Value;
string c = rvwemail.Value;
string d = rvwmsg.Value;
string cnn = ConfigurationManager.ConnectionStrings["dbconnection"].ConnectionString;
MySqlConnection con = new MySqlConnection(cnn);
MySqlCommand cmd = new MySqlCommand("insert into ab_db.rvw(rvw_name,rvw_no,rvw_email,rvw_msg) values('" + a + "','" + b + "','" + c + "','" + d + "')", con);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
答案 0 :(得分:0)
你有
value=""
所有字段
试试这个
value="@Request.Form["name"]"
value="@Request.Form["email"]"