0
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>");

点击此代码给我黑色值为什么?

我尝试了很多但我没有得到它

4

2 回答 2

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);
}

试试看...

于 2013-05-05T07:24:55.473 回答
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 控件的价值。

于 2013-05-05T07:12:15.397 回答