Solved

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

Posted on 2008-06-17
8
193 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 250 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
 

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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now