提交联系表单而不使用jquery刷新页面,在asp.net中使用ajax

时间:2017-02-10 06:12:18

标签: jquery asp.net-ajax email-validation

我已经通过在Google上搜索来尝试了所有内容,但我无法获得我想要的内容。我在Visual Studio 2015中创建这个项目。我想要发送电子邮件的邮件代码和用于发送页面的jquery代码而不刷新它。如果电子邮件已发送且验证中没有错误,则标签应定义 - 感谢您与我们联系......

这是我的代码:

<form id="contactform1" runat="server">
    <div class="contactimage">
        <img src="../Project%20Pics/facilities_1.jpg" />
        &nbsp;
    </div>
    <h1 style="z-index: 1000; position: absolute; text-align: center; top: 110px; left: 650px; font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif; font-size: 45px">Contact Us</h1>
    <asp:TextBox ID="Name" runat="server" CssClass="textbox1" placeholder="Your Name" ToolTip="Type Your Name Here"></asp:TextBox>
    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" Style="top: 210px; z-index: 1000; float: left; color: #FF0000; font-size: 20px; left: 1030px; position: absolute; height: 22px; width: 500px"
        ErrorMessage="* Name is Mandatory"
        ControlToValidate="Name"> 
    </asp:RequiredFieldValidator>

     <asp:RegularExpressionValidator Display = "Dynamic" ControlToValidate="Name" ID="RegularExpressionValidator2"
          ValidationExpression = "^[\s\S]{3,20}$" Style="top: 210px; z-index: 1000; float: left; color: #FF0000; font-size: 20px; left: 1030px;
          position: absolute; height: 22px; width: 500px"
          runat="server" ErrorMessage="Length should be between 3 and 20 characters">

     </asp:RegularExpressionValidator>

    <asp:TextBox ID="Email" runat="server" CssClass="textbox2" placeholder="Your Email" ToolTip="Type Your Email Here"></asp:TextBox>
    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" Style="top: 260px; z-index: 1000; float: left; 
        color: #FF0000; font-size: 20px; left: 1030px; position: absolute; height: 22px; width: 500px"
        ErrorMessage="* Email is Mandatory"
        ControlToValidate="Email"> 
    </asp:RequiredFieldValidator>

     <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" Style="top: 260px;
    left: 1030px; position: absolute; height: 22px; width: 500px; font-size:20px; color:#FF0000;" 
    ErrorMessage="* Please Enter a Valid Email ID" ControlToValidate="Email" 
    ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>

    <asp:TextBox ID="MobileNumber" runat="server" CssClass="textbox3" placeholder="Your Mobile Number" MaxLength="50" ToolTip="Type Your Mobile Number Here"></asp:TextBox>
    <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" Style="top: 310px; z-index: 1000; float: left; 
        color: #FF0000; font-size: 20px; left: 1030px; position: absolute; height: 22px; width: 500px"
        ErrorMessage="* Mobile Number is Mandatory"
        ControlToValidate="MobileNumber"> 
    </asp:RequiredFieldValidator>

    <asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server"
        ControlToValidate="MobileNumber" ErrorMessage="Mobile Number should be of 10 digits"
        Style="top: 310px; z-index: 1000; float: left; color: #FF0000;
        font-size: 20px; left: 1030px; position: absolute; height: 22px; width: 500px"
        ValidationExpression="[0-9]{10}">
    </asp:RegularExpressionValidator>

    <asp:TextBox ID="Subject" runat="server" CssClass="textbox4" placeholder="Subject" ToolTip="Subject" OnTextChanged="TextBox5_TextChanged"></asp:TextBox>
    <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" Style="top: 360px; z-index: 1000; float: left; 
        color: #FF0000; font-size: 20px; left: 1030px; position: absolute; height: 22px; width: 500px"
        ErrorMessage="* Subject is Mandatory"
        ControlToValidate="Subject"> 
    </asp:RequiredFieldValidator>
    <asp:TextBox ID="Message" runat="server" CssClass="textbox5" placeholder="Write Your Message Here" Rows="5" TextMode="MultiLine" ToolTip="Write Your Message"></asp:TextBox>
    <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" Style="top: 430px; z-index: 1000; float: left; 
        color: #FF0000; font-size: 20px; left: 1030px; position: absolute; height: 22px; width: 500px"
        ErrorMessage="* Message is Mandatory"
        ControlToValidate="Message"> 
    </asp:RequiredFieldValidator>
     <div class="submitbutton1">
        <asp:Button ID="Submit" CssClass="SubmitButton" runat="server" Text="Submit" Height="43px" Width="127px" ToolTip="Submit" BackColor="#7CCFF9" ForeColor="#000099" OnClick="Submit_Click" />
    </div>
    <asp:Label ID="Label1" runat="server" Text=" " CssClass="SuccessfulLabel"></asp:Label>
</form>  .SuccessfulLabel {
            position:absolute;
            z-index:1000;
            float:left;
            top: 577px;
            left:554px;
        width: 441px;
        height: 57px;
        font-family:'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
        font-size:25px;
    }

0 个答案:

没有答案