function valid() {
var name = document.getElementById('<%= this.txtname.ClientID %>').value;
var email = document.getElementById('<%= this.txtemail.ClientID %>').value;
var phone = document.getElementById('<%= this.txtmobile.ClientID %>').value;
var city = document.getElementById('<%= this.txtcity.ClientID %>').value;
mobilecon = /^\d{10}$/;
emailcon = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([com\co\.\in])+$/;
if (name == "" || email == "" || phone == "" || city == "") {
swal("Please fill all details to proceed..!", "", "warning");
return false;
}
if (phone != '') {
if (!phone.match(mobilecon)) {
swal("Please Enter Valid Contact Number", "", "info");
return false;
}
}
if (email != '') {
if (!email.match(emailcon)) {
swal("Please Enter Valid Email-Id", "", "info");
return false;
}
}
return true;
}
Add Master Page from Add New Item --> Master Page then we can add child pages from Add New Item-->Web form with Master Page
IsPostBack Gets a value that indicates whether the page is being rendered for the first time or is being loaded in response to a postback.
It returns boolean value-true if the page is being loaded in response to a client postback; otherwise, false.
We need to bind values to city dropdown list on page load
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>IsPostBack Example</title>
</head>
<body>
<form id="form1" runat="server">
<div style="margin-top:50px">
<h3>IsPostBack Example</h3>
<asp:Button runat="server" OnClick="btnrefresh_Click" ID="btnrefresh" Text="Postback Request" />
<br />
<asp:DropDownList runat="server" style="margin-top:15px" ID="ddlcity"></asp:DropDownList>
</div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Training
{
public partial class ispostback : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Response.Write("Page is loaded for first time..!");
bindddl();
}
}
protected void bindddl()
{
ListItem li1 = new ListItem("Kolhapur");
ddlcity.Items.Add(li1);
ListItem li2 = new ListItem("Pune");
ddlcity.Items.Add(li2);
ListItem li3 = new ListItem("Mumbai");
ddlcity.Items.Add(li3);
ListItem li4 = new ListItem("Delhi");
ddlcity.Items.Add(li4);
}
protected void btnrefresh_Click(object sender, EventArgs e)
{
}
}
}