Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / November 2007

Tip: Looking for answers? Try searching our database.

Closing a window from code behind

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jeremy - 22 Nov 2007 00:11 GMT
Looks like this is either too obvious for anyone to address, or it just
isn't done by anyone.  There was a question in early sep this year that no
one replied to, and I don't find any other references.  So here goes again:

I want to close my popup from an asp codebehind event handler.  The
following does not work (this is an event handler for the Login control)

       protected void OnLoggedIn(object sender, EventArgs e)
       {
           Response.Write ("<script language =
javascript>close();</script>");
       }

Instead of closing the window and returning to the calling window, the
calling page is opened (again) in the same window.

Jeremy
Nick Chan - 22 Nov 2007 01:36 GMT
try putting Response.End after it

did u try debug break in onloggedin? does it go there?

> Looks like this is either too obvious for anyone to address, or it just
> isn't done by anyone.  There was a question in early sep this year that no
[quoted text clipped - 13 lines]
>
> Jeremy
Jeremy - 22 Nov 2007 01:56 GMT
Nick, bless you!  Response.end() is the answer.

Mark Rae, in a different thread is saying that this technique of pumping
script into html is a bad thing.  Unfortunately, I don't know any other way
to get the window closed from codebehind.  Is there some other technique? He
suggests registering a client script, but that begs the question; how to
call the script from codebehind?

Jeremy

> try putting Response.End after it
>
[quoted text clipped - 19 lines]
>>
>> Jeremy
Jon Gonzales - 22 Nov 2007 03:12 GMT
This is the only way, always remember that manipulating windows occur in the
client side, hence the client side script is use to meet this requirements.

> Nick, bless you!  Response.end() is the answer.
>
[quoted text clipped - 29 lines]
> >>
> >> Jeremy
Nick Chan - 22 Nov 2007 03:31 GMT
it is very odd that in your case response.write without response.end
wont work
maybe it has something to do with login control

if response.write without response.end wont work, i doubt registering
client script will

anyway, to register client script :

Page.ClientScript.RegisterStartupScript(Page.GetType,
"scriptName_FreeText", "<script type=""text/javascript"">close()</
script>")

(or RegisterClientScript, i think!)

> Nick, bless you!  Response.end() is the answer.
>
[quoted text clipped - 31 lines]
>
> - Show quoted text -

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.