Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Closing a window using a ASP:ImageButton

Reply
Thread Tools

Closing a window using a ASP:ImageButton

 
 
thechaosengine
Guest
Posts: n/a
 
      04-28-2005
Hi all,

I need to be able to cause the following chain of events after clicking an
asp:button but I don't know how to do it. I'd really appreciate any advice
on this or alternative approaches:

The window in question is a popup asking the user to provide some details.
The primary window is still open in the background

1. Button on popup clicked
2. Information on form saved to database
3. Popup closes
4. Primary window refreshes or is redirected

I really hope someone can advise on how to achieve this

Thanks all

tce


 
Reply With Quote
 
 
 
 
mortb
Guest
Posts: n/a
 
      04-28-2005
You'd have to out put some javascript to your page after its postback.
Use the Page.RegisterStartupScript method.

popup codebehind:

void button_onclick(...)
{
// add code to save data to DB

yourjavascript = "<script language='javascript'>";
yourjavascript += "self.parent.location = self.parent.location.href;
// this will refresh your parent window.";
yourjavascript += "self.close(); // close popup";
yourjavascript += "</script>"
Page.RegisterStartupScript( yourJavascript):
}


"thechaosengine" <none> wrote in message
news:(E-Mail Removed)...
> Hi all,
>
> I need to be able to cause the following chain of events after clicking an
> asp:button but I don't know how to do it. I'd really appreciate any advice
> on this or alternative approaches:
>
> The window in question is a popup asking the user to provide some details.
> The primary window is still open in the background
>
> 1. Button on popup clicked
> 2. Information on form saved to database
> 3. Popup closes
> 4. Primary window refreshes or is redirected
>
> I really hope someone can advise on how to achieve this
>
> Thanks all
>
> tce
>
>



 
Reply With Quote
 
 
 
 
Karl Seguin
Guest
Posts: n/a
 
      04-28-2005
In the image click event, after saving the information, do something like:

dim script as string = "<script language=""javascript"">" &
System.Environment.NewLine & "self.close();" & System.Environment.NewLine &
"</script>"
Page.RegisterStartupScript("PopupClose", script)


Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)


"thechaosengine" <none> wrote in message
news:(E-Mail Removed)...
> Hi all,
>
> I need to be able to cause the following chain of events after clicking an
> asp:button but I don't know how to do it. I'd really appreciate any advice
> on this or alternative approaches:
>
> The window in question is a popup asking the user to provide some details.
> The primary window is still open in the background
>
> 1. Button on popup clicked
> 2. Information on form saved to database
> 3. Popup closes
> 4. Primary window refreshes or is redirected
>
> I really hope someone can advise on how to achieve this
>
> Thanks all
>
> tce
>
>



 
Reply With Quote
 
Karl Seguin
Guest
Posts: n/a
 
      04-28-2005
oppss..I forgot the parent refresh in mind well, now you have the c# and
vb.net version...just add mort's self.parent.location... to my script
variable if you need it in vb.net

On the flip side, RegisterStartupScript always takes 2 parameters...the
first being the key...

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)


"mortb" <mortb1<noospam<@hotmail.com> wrote in message
news:uS4gGL%(E-Mail Removed)...
> You'd have to out put some javascript to your page after its postback.
> Use the Page.RegisterStartupScript method.
>
> popup codebehind:
>
> void button_onclick(...)
> {
> // add code to save data to DB
>
> yourjavascript = "<script language='javascript'>";
> yourjavascript += "self.parent.location =
> self.parent.location.href; // this will refresh your parent window.";
> yourjavascript += "self.close(); // close popup";
> yourjavascript += "</script>"
> Page.RegisterStartupScript( yourJavascript):
> }
>
>
> "thechaosengine" <none> wrote in message
> news:(E-Mail Removed)...
>> Hi all,
>>
>> I need to be able to cause the following chain of events after clicking
>> an asp:button but I don't know how to do it. I'd really appreciate any
>> advice on this or alternative approaches:
>>
>> The window in question is a popup asking the user to provide some
>> details. The primary window is still open in the background
>>
>> 1. Button on popup clicked
>> 2. Information on form saved to database
>> 3. Popup closes
>> 4. Primary window refreshes or is redirected
>>
>> I really hope someone can advise on how to achieve this
>>
>> Thanks all
>>
>> tce
>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Closing popup window when closing parent window? =?Utf-8?B?Vk1J?= ASP .Net 3 02-15-2007 08:29 AM
Closing sub window from parent window Satya ASP .Net 0 12-15-2005 05:27 PM
Closing child window when opening a new Window Patrick Olurotimi Ige ASP .Net 2 12-14-2004 04:59 AM
Closing child window and refreshing Parent window automatically =?Utf-8?B?U2lsZWVzaA==?= ASP .Net 4 10-14-2004 02:01 AM
Closing child window WITHOUT closing parent thomas Javascript 0 10-23-2003 04:10 PM



Advertisments