?
Solved

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

Posted on 2008-06-17
8
Medium Priority
?
206 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
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
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
Course of the Month13 days, 18 hours left to enroll

807 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