我是C#,ASP.NET中的初學者。 我想要的是當點擊「提交」按鈕時,需要顯示一條消息'您的註冊成功'。 但是,當我點擊這裏,沒有任何顯示,但它顯示其他電腦相同的代碼的消息。 有人可以幫助我嗎?我的項目中是否有配置錯誤?在c中顯示消息#
代碼在這裏:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Windows.Forms;
public partial class Registration : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void submit_Click(object sender, EventArgs e)
{
Response.Write("Your registration is succesful"); // Not displaying
//MessageBox.Show("Test Display");
}
}
ASP.NET
<form id="form1" runat="server">
<div>
</div>
<table class="style1">
<tr>
<td class="style3">
Username</td>
<td class="style6">
<asp:TextBox ID="uname" runat="server" Width="180px"></asp:TextBox>
</td>
<td class="style8">
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="uname" ErrorMessage="Username is required" ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style3">
Email</td>
<td class="style6">
<asp:TextBox ID="email" runat="server" Width="180px"></asp:TextBox>
</td>
<td class="style8">
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="email" ErrorMessage="Email is required" ForeColor="Red"></asp:RequiredFieldValidator>
<br />
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="email" ErrorMessage="You must enter the valid email id"
ForeColor="Red"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td class="style3">
Password</td>
<td class="style6">
<asp:TextBox ID="pass" runat="server" TextMode="Password" Width="180px"></asp:TextBox>
</td>
<td class="style8">
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="pass" ErrorMessage="Password is required" ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style3">
Confirm Password</td>
<td class="style6">
<asp:TextBox ID="passr" runat="server" TextMode="Password" Width="180px"></asp:TextBox>
</td>
<td class="style8">
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate="passr" ErrorMessage="Confirm password is required"
ForeColor="Red"></asp:RequiredFieldValidator>
<br />
<asp:CompareValidator ID="CompareValidator1" runat="server"
ControlToCompare="pass" ControlToValidate="passr"
ErrorMessage="Both passwords must be same" ForeColor="Red"></asp:CompareValidator>
</td>
</tr>
<tr>
<td class="style3">
Country</td>
<td class="style6">
<asp:DropDownList ID="country" runat="server" Width="180px">
<asp:ListItem>Select Country</asp:ListItem>
<asp:ListItem>USA</asp:ListItem>
<asp:ListItem>UK</asp:ListItem>
<asp:ListItem>GERMANY</asp:ListItem>
<asp:ListItem>FRANCE</asp:ListItem>
<asp:ListItem>INDIA</asp:ListItem>
</asp:DropDownList>
</td>
<td class="style8">
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server"
ControlToValidate="country" ErrorMessage="Select a country name"
ForeColor="Red" InitialValue="Select Country"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style4">
</td>
<td class="style7">
<asp:Button ID="submit" runat="server" Text="Submit" />
</td>
<td class="style5">
<input id="Reset1" type="reset" value="reset" /></td>
</tr>
<tr>
<td class="style2">
</td>
<td class="style6">
</td>
<td>
</td>
</tr>
</table>
</form>
'MessageBox'只對其運行的Web服務器是本地的,不應該與asp一起使用。net –
您認爲應該在什麼電腦上顯示消息框?事實上,你相信這段代碼做了一些有用的事情,這表明你可能對ASP.NET的工作原理有一個概念上的問題。 ASP在* server *上運行代碼,* *將* text *發送給* client *。這個模型是否清晰? –
「ASP.NET」中沒有'MessageBox.Show' – Rahul