Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2008-06-17
8
Medium Priority
?
202 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
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 

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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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

618 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