Giri
Giri

Reputation: 941

How to display response message after redirecting to otherpage?

I am using ASP.NET and C#.In register page after click on submit i am storing all the details in database and redirecting to login page.So in login page i need to display message like successfully registered.

Can someone tell me is it possible?

Thanks.

Upvotes: 0

Views: 11206

Answers (5)

Cyberpks
Cyberpks

Reputation: 1421

After you have registered the user successfully, use

Response.Redirect("YourLoginPage.aspx?status=registered");

and in YourLoginPage.aspx page,

string strStatus = Request.QueryString["status"].ToString();
if(strStatus.ToUpper()=="REGISTERED")
Response.Write("You are registered successfully"); // or place it in any label.

In case you want to login him at the same time, you can user Session to store authentication details and call login method, at the same time.

Upvotes: 2

user841123
user841123

Reputation:

You may use Session, QueryString, Cookie for this purpose.

But I would suggest show you message on same Register page. And put continue button on page, that will redirect user to Home or other page.

Why I`m saying show message on same page, because one thing is fixed you are going to redirect user if registration was successful, if not you will show the errors.

Session, QueryString will be easy and handy option for this:

Session["RegisterMessage"] = "Hello User, You have successfully registered";

Or

Response.Redirect("Home.aspx?msg=Hello User, You have successfully registered");

You may show this value on label on the page.

Upvotes: 2

Vikram Jain
Vikram Jain

Reputation: 5588

You should store message or information in session or on page of login.

On page load check if the session or message is not empty then display message via alert box using javascript.

Upvotes: 1

Guo Hong Lim
Guo Hong Lim

Reputation: 1710

You can create a label on the login page and once you response.redirect the user to the login page, you can pass a session or querystring on the fact that they have successfully registered.

On the login page, on the onload event handler, check if the querystring / session contains whatever you inserted, if it has, display the message in the label, else disregard.

Upvotes: 2

عثمان غني
عثمان غني

Reputation: 2708

Use Query String to pass the Message to Login Page and show with the help of Label.

Upvotes: 2

Related Questions