?
Solved

Showing message to a user with "Ok" button in a webform

Posted on 2008-06-17
8
Medium Priority
?
200 Views
Last Modified: 2013-11-26
Hi,

       I want to show a message to the user.The message  box shud have only "OK" button in it.
Once the user clicks that button, user shud be redirected to "Home.aspx".

Can it be done in c# itself or have to use js???

Urgent,

Thanks.
0
Comment
Question by:srk1982
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 6

Accepted Solution

by:
psychic_zero earned 750 total points
ID: 21809349
You can use javascript
<SCRIPT LANGUAGE="JavaScript">
<!-- Beginning of JavaScript -
 
function MsgBox() 
{
   alert ("Pleass press OK");
   window.location = "Home.aspx"  // Your redirect page
}
 
// - End of JavaScript - -->
</SCRIPT>
 
...
 
<INPUT NAME="goto" TYPE="Button" VALUE="Go to Page" onClick="MsgBox()">

Open in new window

0
 
LVL 7

Expert Comment

by:Zippit
ID: 21809362

<script>
 
alert("My Alert");
 
window.location = "http://www.mysite.com/Home.aspx";
 
</script>

Open in new window

0
 

Author Comment

by:srk1982
ID: 21809657
Hi psychic_zero,

    I have to call this javascript function in my pageload and not in a click event.
How to do that?
0
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 

Author Comment

by:srk1982
ID: 21809766
Hi psychic_zero,

Page load of my code behind
like we give for a button click like this
btnDelete.Attributes.Add("OnClick","return ValidateDelete()");

in my case i just want to call that MsgBox() in the pageload of my codebehind.
0
 
LVL 6

Expert Comment

by:psychic_zero
ID: 21809829
Sorry I'm not quite understand with pageload of my codebehind. Or maybe you can give me the flow of how do you want it to work like:

From page "Intro.aspx" -> click on a "Home" button -> then a message box will appear said "You will be redirect to Home page" with OK button -> click OK button on the message box -> then the page will open "Home.aspx".
0
 

Author Comment

by:srk1982
ID: 21809960
I want to call the msgbox() when the Intro.aspx page loads.
The reason why I want to call this msgbox() in codebehind of Intro.aspx because i have to check some session values there.
Thanks
0
 
LVL 6

Expert Comment

by:psychic_zero
ID: 21810259
So you want function msgbox() to be executed automatically when page intro.aspx is load? Then how about try this code below. At the body tag, add onload function and see how it goes.
<body onload="MsgBox()">

Open in new window

0
 

Author Comment

by:srk1982
ID: 21810291
Hi psychic_zero,,

   i dont want to do that in <body> tag, since this message has to come after checking some session values in my codebehind[c#].so, i have to do this in my codebehind only.

Anyway, i did that in c#, it is working now.

Thanks.
						string strMessage = "Page not available for selected class.";
						string strScript = "<script language=JavaScript>";
						strScript += "alert(\"" + strMessage + "\");";
						strScript += "window.location = \"admListQuote.aspx\"";
						strScript += "</script>";
				
						if (! (Page.IsStartupScriptRegistered("clientScript")))
						{
							Page.RegisterStartupScript("clientScript", strScript);
						}

Open in new window

0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question