index.aspx page code
<asp:Label ID="Button" runat="server"></asp:Label>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<cc1:ModalPopupExtender ID="mp1" runat="server" PopupControlID="Panl1" TargetControlID="Button"
CancelControlID="Button2" BackgroundCssClass="Background" >
</cc1:ModalPopupExtender>
<asp:Panel ID="Panl1" runat="server" CssClass="Popup" Style="display: none">
<div class="cancelbtn">
<asp:Button ID="Button2" runat="server" Text="x" />
</div>
<iframe style="width: 400px; height: 350px; border:none; border-right:8px" id="irm1" src="PopupMenu.aspx" runat="server"></iframe>
</asp:Panel>
index.aspx.cs page code
public partial class WebForm1 : System.Web.UI.Page
{
/*Some code here*/
public void HidePopup()
{
mp1.Hide();
}
}
I have another page where i write code of popup
Popup.aspx page code
<form id="form1" runat="server">
<div class="registration">
<div class="registrationtext">Enruiry</div>
<div class="my-label">
<span>Full Name </span>
<span>
<asp:TextBox ID="TextBoxFullName" runat="server"></asp:TextBox></span>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBoxFullName" ErrorMessage="*" Width="16px"></asp:RequiredFieldValidator>
</div>
<div class="my-label">
<span>Email id </span>
<span>
<asp:TextBox ID="TextBoxEmail" runat="server"></asp:TextBox></span>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="TextBoxEmail" ErrorMessage="*"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="Email" runat="server" ControlToValidate="TextBoxEmail" ErrorMessage="*" ToolTip="Enter Valid email address" Display="Dynamic" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
</div>
<div class="my-label">
<span>State</span>
<span>
<asp:TextBox ID="TextBoxState" runat="server"></asp:TextBox></span>
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="TextBoxState" ErrorMessage="*"></asp:RequiredFieldValidator>
</div>
<div class="my-label">
<span>City </span>
<span>
<asp:TextBox ID="TextBoxCity" runat="server"></asp:TextBox></span>
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ControlToValidate="TextBoxCity" ErrorMessage="*"></asp:RequiredFieldValidator>
</div>
<div class="my-label">
<span>Mobile No. </span>
<span>
<asp:TextBox ID="TextBoxMobile" runat="server"></asp:TextBox></span>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="TextBoxMobile" ErrorMessage="*"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="TextBoxMobile" ErrorMessage="*" ValidationExpression="[0-9]{10}"></asp:RegularExpressionValidator>
<div style="margin: 10px 0 -17px 96px; float:right">
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" BackColor="White" Font-Bold="True" />
</div>
</div>
<br />
<a href="#" style="text-decoration:none"><asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Size="Large" ForeColor="Red"></asp:Label></a>
</div>
Popup.aspx.cs page code
protected void btnSubmit_Click(object sender, EventArgs e)
{
string con = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
try
{
if (Page.IsValid)
{
using (SqlConnection connection = new SqlConnection())
{
connection.ConnectionString = con;
SqlCommand cmd = new SqlCommand();
cmd.Connection = connection;
cmd.CommandText = "spInsertEnquiry";
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@fname", TextBoxFullName.Text);
cmd.Parameters.AddWithValue("@email", TextBoxEmail.Text);
cmd.Parameters.AddWithValue("@state", TextBoxState.Text);
cmd.Parameters.AddWithValue("@city", TextBoxCity.Text);
cmd.Parameters.AddWithValue("@mobilephone", TextBoxMobile.Text);
connection.Open();
cmd.ExecuteNonQuery();
}
}
}
catch
{
}
WebForm1 ob = new WebForm1();
ob.HidePopup();
}
Error : object reference not set to an instance