Redirect aspx page

T

Tom

Hi,

I have an index.aspx page which includes top.aspx,
left.aspx, main.aspx and bottom.aspx.

In the left.aspx, there is a login web control -
login.ascx. It keeps session of username and role after
successful login and shows welcome user message and his
shopping cart link.

The page which shows welcome user message and his shopping
cart link called loginsuccess.ascx. Now, I am not sure how
to deal with the redirect page.

Here is the session code in login.ascx:
Code:
case LOGIN_SUCCESS:
Session["UserName"] = UserName;
Session["Role"] = Role;
Response.Redirect("loginsuccess.ascx",true);
break;

I want to redirect page to be the same index.aspx which
has the same top.aspx, left.aspx, role.aspx and
bottom.aspx. In the left.aspx and main.aspx pages, I want
login.ascx turns to loginsuccess.ascx and main.aspx to
role.aspx according to the username and role.

How can I do it?

Thanks
 
E

Eric Veltman

Tom said:
I want to redirect page to be the same index.aspx which
has the same top.aspx, left.aspx, role.aspx and
bottom.aspx. In the left.aspx and main.aspx pages, I want
login.ascx turns to loginsuccess.ascx and main.aspx to
role.aspx according to the username and role.
How can I do it?

Hello Tom,

I assume you're using frames and index.aspx contains the
frameset definitions ? When you redirect, you redirect the
whole browser window, not just the left part, so you have
to redirect to index.aspx. You could pass a parameter like :
Response.Redirect("index.aspx?Page=role.aspx",true);

Then index.aspx has to look at the "Page" URL parameter
to decide which page to load in the main frame.

From Page_Load in left.aspx, you can look at the session
variables to see if the user logged in, if he did,
you hide login.ascx and show loginsuccess.ascx, if he didn't,
you hide loginsuccess.ascx and show login.ascx.

You can also decide to dynamically load ( with LoadControl() )
login.ascx or loginsuccess.ascx instead of hiding and showing.

Another advice would be to stop using frames and use table
cells instead to split up your window in top,bottom,left,main.
To make the main part scrollable, you can use style="overflow:auto".
When you get rid of frames, you'll see that it's easier to write
web applications, because from the same index.aspx, you can now
easily access controls on all parts of the screen without having
to do ugly redirect tricks.

Best regards,

Eric
 
T

Tom

Dear Eric,


You can also decide to dynamically load ( with LoadControl
() ) login.ascx or loginsuccess.ascx instead of hiding and
showing.

Could you tell me some online tutorial or code example for
teaching LoadControl()?

Another advice would be to stop using frames and use table
cells instead to split up your window in
top,bottom,left,main.
To make the main part scrollable, you can use
style="overflow:auto".

Actually, I did not use frames. I use server side include
and web control. I want the whole page to be scrollable,
but not just the main part.

What do you suggest to maintain a web site which has
constant pages for top, left and bottom if not use server
side include and frames? (and whole page needs to be
scrollable)

Thanks for your kind help

Tom
 
E

Eric Veltman

Hello Tom,
Could you tell me some online tutorial or code example for
teaching LoadControl()?

..NET is documented very well, the Microsoft MSDN site
contains lots of information, including articles and
a class library reference in the library section.
The below URL points to a howto for LoadControl.

http://tinyurl.com/wrco

Note that though the example adds the dynamically loaded
control to the Page's Controls collection, you can add it
to any child controls' Controls collection as well.
What do you suggest to maintain a web site which has
constant pages for top, left and bottom if not use server
side include and frames? (and whole page needs to be
scrollable)

The way I did this was by having a single Page with all
the common layout and using UserControls as modules that
were dynamically loaded in the PlaceHolder on the main
section of the Page, depending on the "Page" URL parameter
received by the Page. In my case, the left part of the
Page would contain a PlaceHolder too, and the module
would load the appropriate UserControl there.

So to open the news "Page", the URL would be
http://somehost/index.aspx?Page=news
which would make index.aspx load news.ascx

And to open the myprofile "Page", the URL would be
http://somehost/index.aspx?Page=myprofile
which would make index.aspx load myprofile.aspx

If you want you can even create several layers
of templates, f.i. index.aspx containing everything
common for all pages, newsitem.ascx containing everything
common for all types of news items, sportnewsitem.ascx
containing everything common for sport news items, etc.
A URL could then look like :
http://somehost/index.aspx?Page=newsitem/sportsnewsitem&Article=26

I believe I learnt this from :
http://www.smartisans.com/articles/vb_templates.aspx

Best regards,

Eric
 

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

Top