pop Up Window from .cs file

S

SJ

Is it possible to pop-up a window from the code-behind
aspx.cs file on an OnClick event?
If so, how?
I've tried something like the following, but it doesnt seem to work.
private void MyButton_Click(object sender, System.Web.UI.ImageClickEventArgs
e)

{

Response.Write("<script>window.open('mypopUp_dialog.aspx');<script>");

}

I don't want to use in-line javascript code or use a <script> tag within my
aspx file
itself.
 
B

Brock Allen

Check out Page.RegisterClientScriptBlock. It asks the page to emit a block
of js for you. You can then call that from, say, an onclick event.
 
S

SJ

Well, I dont think that is going to work for me either.
Basically, what I'm trying to do is something like this

website.aspx:
<form id="form1" runat="server">
<asp:TextBox id="Mytext" runat="server" />
<asp:imageButton id="ResetButton" imageURL="blah.gif" runat="server" />
</form>

website.aspx.cs:
private void ResetButton_Click(object sender,
System.Web.UI.ImageClickEventArgs e)
{
// Code that will pop-up a window

// "form1" Processing
}

As you can see above, I need 2 things to happen when the "ResetButton" is
clicked.
a) form submission and processing in the _Click event handler
b) Popup a window

Now, if I use regular HTML buttons, I can use an
"onClick=someJavascriptFunction()" event in the website.aspx to pop-up a
window, but that prevents me from submitting/processing the form data using
the ResetButton_Click event handler in the website.aspx.cs file.
I know that I could do form submission from the someJavascriptFunction() ,
but I dont want to do that.

I need the code-behind to open this pop-up window. If thats even possible.

I hope that makes sense?

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,796
Messages
2,569,645
Members
45,371
Latest member
TroyHursey

Latest Threads

Top