Videos
If I understand you correctly, you don't need a popup, you just trying to activate some div on your page. You will need to make this div server side
<div class="popup" runat="server" style="display:none" id="divPop">
<asp:TextBox ID="_lname" runat="server"></asp:TextBox>
<asp:Button ID="Button1"
runat="server"
Text="save" OnClick="Button1_Click"
/>
</div>
and then in your server side click
protected void btnOpenPopupWindow_Click(object sender, EventArgs e)
{
divPop.Attributes.Add("style", "display:block);
}
this will make your div visible
EDIT better solution in your case would be using asp panel instead of div.
<asp:panel id="divPop" visible="false" runat="server">
<asp:TextBox ID="_lname" runat="server"></asp:TextBox>
<asp:Button ID="Button1"
runat="server"
Text="save" OnClick="Button1_Click"
/>
</asp:panel>
and then you will be able to manipulate visibility in your server side code very easy
protected void btnOpenPopupWindow_Click(object sender, EventArgs e)
{
divPop.Visible=true;
}
you are using server side control in your code.
<asp:Button ID="btnOpenPopupWindow"
runat="server"
Text="Open Popup Window" OnClick="btnOpenPopupWindow_Click"
/>
click of this button will trigger immediate post to the server and server (your ASP.NET application) will handle the event. The only way you will be able to open a popup from the server if you will register script to do this. Your CLick should look something like
protected void btnOpenPopupWindow_Click(object sender, EventArgs e)
{
ClientScript.RegisterStartupScript(this.GetType(),
"yourWindowName",
String.Format("<script>window.open('{0}');</script>", yourURL));
}
You can use ClientScript.RegisterStartupScript
In C#
protected void Button1_Click(object sender, EventArgs e)
{
string queryString = "test.aspx" ;
string newWin ="window.open('" + queryString + "');";
ClientScript.RegisterStartupScript(this.GetType(), "pop", newWin, true);
}
In VB
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim queryString As String = "test.aspx"
Dim newWin As String = "window.open('" & queryString & "');"
ClientScript.RegisterStartupScript(Me.GetType(), "pop", newWin, True)
End Sub
Opening a web page or web form in modal popup window in ASP.NET is easy using jQuery:
$(function () {
modalPosition();
$(window).resize(function () {
modalPosition();
});
$('.openModal').click(function (e) {
$('.modal, .modal-backdrop').fadeIn('fast');
e.preventDefault();
});
$('.close-modal').click(function (e) {
$('.modal, .modal-backdrop').fadeOut('fast');
});
});
function modalPosition() {
var width = $('.modal').width();
var pageWidth = $(window).width();
var x = (pageWidth / 2) - (width / 2);
$('.modal').css({ left: x + "px" });
}
Refer to: open a web page in modal popup in asp.net using jquery
Use this code
<asp:TableCell>
<asp:Button ID="btnSearch" Text="Search" OnClientClick="openwd();" runat="server"/>
</asp:TableCell>
<script type = "text/javascript>
function openwd() {
window.open("OnPopUp.aspx");
return false;
}
</script>
user controls in asp.net has the extension .ascx . In your example you r calling OnPopUp.aspx, rather it should be OnPopUp.ascx