Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Closing a window when processing a sub...

Status
Not open for further replies.

onedizzydevil

Programmer
Mar 24, 2001
103
US
I have a pop-up window named "login". When processing btnLogin_Click if the login is valid, I need to refresh the opener and close the window automatically.

Any ideas.

Thanks


Wayne Sellars

"Programming, today is a race between software developers, striving to build bigger and better idiot-proof programs, and the Universe, trying to produce bigger and better idiots. So far, Universe 1 - Programmers 0."
 
Option #1:
When the login is successful, an entry is written to some database table. The Login window closes (using javascript). The main window has code so that it will postback ever 10 seconds or so and check so see if that record has been written. If yes, then it redirects to whatever page you want.

Option #2:
Unless you have to, don't use the popup: just have the login on the main page and proceed from there. We just finished a chat app where we had to play with pop-ups, and it was HELL!

I'm really hoping that once more documentation about JScript.NET and J#.NET comes out, alot of these things won't be so difficult, but right now with vb.net and c# being the only main asp.net languages, I'm afraid we're probably stuck with a bit of clunkiness.

Jack
 
Ideally I would like to have login on everypage so they could login no matter where they are at in the public site. Put this turned out to be pure heck, because you can not have more than one server side form and you can not have a form in a form and etc etc.

So then you start having problems when you have a public forms that can be submitted without being logged in and all of this crap; therefore, I try to keep all the forms on separate pages. I just don't feel I have the control in .NET as I did in classic ASP but I have more functionality in .NET.

Wayne Sellars

"Programming, today is a race between software developers, striving to build bigger and better idiot-proof programs, and the Universe, trying to produce bigger and better idiots. So far, Universe 1 - Programmers 0."
 
So what is wrong with "onclick='window.close()'" on an input button, so instead of trying to close the window when the login is succesful, you re-display the window if it is not?
 
I need it to work in a sub using VB. Wayne Sellars

"Programming, today is a race between software developers, striving to build bigger and better idiot-proof programs, and the Universe, trying to produce bigger and better idiots. So far, Universe 1 - Programmers 0."
 
Hey Wayne,

have you considered making a custom control?

Your control can be made using a panel, some textboxes, and a login button. the username/password gets passed to the control, and you have all the code behind to deal with the logging in. This way, all you have to do is put the control on each of your pages, and you don't have to worry about seperate forms or anything.

Jack
 
I am using a user control now, I just can not use it the way it is, I have to change the validation methods.

I use the validators which can not be used be if you have a button anywhere in the form, the validators will kick in and stop the form from being submitted even though all I want to do is transition though pages.

I just have to redo the error checking, again, which is a pain in the butt. The only way I could work around it was to put it in a pop-up but I can not get the page to close and reload the opener.

Thanks Wayne Sellars

"Programming, today is a race between software developers, striving to build bigger and better idiot-proof programs, and the Universe, trying to produce bigger and better idiots. So far, Universe 1 - Programmers 0."
 
Wayne,

I hear ya! I am just moving to c# .net from ColdFusion. Now CF is often completely horrid to work with but I recently encountered the same problem as you are having with .net - at least in CF I knew how to do this "simple" task because I would just use javascript output when appropriate. There seems to be no way to close a popup page from one of your code behind routines (at least not that I could find - but I will point out that this is my first asp.net app). Thankfully mine is an internal app and I can just tell them to close the popup window and refresh the related report for now.

So if you discover anything, please post it here and I will do likewise. Crystal
crystalized_s@yahoo.com

--------------------------------------------------

Experience is one thing you can't get for nothing.

-Oscar Wilde

 
This is some information I received from another board. Keep in mind that I have not tried this yet, no time; however, just by reading the code I can see how it would work. Let me know if it does not work.

---------o snip o---------

You will need to either response.write javascript or assign javascript to a literal.

[tt]literal1.text = &quot;<script language=&quot;javascript&quot;>window.close;window.opener.location.reload();</script>&quot;

<asp:Literal id=&quot;Literal1&quot; runat=&quot;server&quot;></asp:Literal> [/tt]

would do the trick, then when the page is done posting back(your sub is complete) the javascript will run.

---------o snip o--------- Wayne Sellars

&quot;Programming, today is a race between software developers, striving to build bigger and better idiot-proof programs, and the Universe, trying to produce bigger and better idiots. So far, Universe 1 - Programmers 0.&quot;
 
Wayne,

I might find time to try that myself, but like you I don't know if I will have time. I also see how this could work, but I also think that it is really disappointing that they (they being Microsoft) have not added a feature to one of the objects like the page object to do it in a more straightforward, less contrived fashion.

Oh well just my 2 cents.

Thanks for posting the information you found.

Crystal Crystal
crystalized_s@yahoo.com

--------------------------------------------------

Experience is one thing you can't get for nothing.

-Oscar Wilde

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top