473,382 Members | 1,258 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Closing a window using a ASP:ImageButton

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
Nov 19 '05 #1
3 1711
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:10*********************@news.microsoft.com...
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

Nov 19 '05 #2
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:10*********************@news.microsoft.com...
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

Nov 19 '05 #3
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:uS****************@TK2MSFTNGP15.phx.gbl...
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:10*********************@news.microsoft.com...
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


Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: JIM | last post by:
Hello, Does anyone knows how to set the visible property of an asp:Imagebutton to true with javascript I've the following declared : <asp:ImageButton Id="tstImage" runat="server"...
1
by: Michael Evanchik | last post by:
The following tag works fine in internet explorer, but in mozilla the image is not sized and left at its actualy size. Anyone know why? I though asp.net works on any browswer. ...
2
by: Alan Scott | last post by:
I am using the following code to redirect users to another webpage when they click on an image: Response.Redirect("login.aspx"); The code works. However, I have frames setup and would like the...
1
by: Ren | last post by:
I am creating a profile page which on load only has the images of each person (as an ImageButton). When the user clicks on a picture, the text of a hidden label is displayed with the text of that...
5
by: Alex D. | last post by:
Does any body knows how to link an asp:textbox to an asp:imagebutton, both inside a User Control in asp.net 2 beta 2? So when a user enter some text in the textbox and press the "Enter" key the...
13
by: tperri | last post by:
I have an HTML table with several fields like this: <A href="Savings.aspx?category=Food"><asp:imagebutton id="imgFood" ImageUrl="images\buttons\btn-food-i.gif"...
1
by: Shapper | last post by:
Hello, I have 2 Asp:ImageButton in my .aspx file and I have the function "Run" in m .aspx.vb file. I need to run this function when one of the ImageButtons is pressed but I need to know which...
2
by: Dariusz Tomon | last post by:
Hi I got task to make my application much more attractive :( First of all I have to add hover (mouseover) effect to several buttons - imagebuttons - I only know manner with Java Script - but it...
0
by: Stan SR | last post by:
Hi, I need to customize a pargertemplate with these items a arrow to go back to the 1rst page a arrow for the previous page a dropdownlist with the page indexes a arrow for the new page a...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.