String name, gender, DOB, email, mob, land, address, state, city, pincode;
name = txtname.Text.Trim();
gender = RadioButtonList1.SelectedValue;
DOB = txtDob.Text.Trim();
email = txtemail.Text.Trim();
mob = txtmob.Text.Trim();
land = txtlandline.Text.Trim();
address = txtaddress.Text.Trim();
state = txtstate.Text.Trim();
city = txtcity.Text.Trim();
pincode = txtpincode.Text.Trim();
Response.Write("<script>alert('"+email+"')</script>");
这个代码点击给我黑色值为什么??
我尝试了很多,但我没有得到它
答案 0 :(得分:0)
我尝试了以下示例,但它确实有效。如果您有任何其他问题,请与我们联系。
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<p>
<asp:TextBox ID="txtemail" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
</p>
按钮点击的代码隐藏是
protected void Button1_Click(object sender, EventArgs e)
{
String name, gender, DOB, email, mob, land, address, state, city, pincode;
email = txtemail.Text.Trim();
Response.Write("<script> alert('" + email + "')</script>");
}
此外,调试代码并查找是否获得txtemail控件的值。
答案 1 :(得分:0)
如果您想弹出警报电子邮件ID,可以尝试使用以下代码
protected void Button1_Click(object sender, EventArgs e)
{
String name, gender, DOB, email, mob, land, address, state, city, pincode;
email = txtemail.Text.Trim();
ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('"+ email "');", true);
}
尝试一下......