473,695 Members | 2,752 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

javascript alert() after post back c#

PH
Does anyone know how to have the pop-up javascript alert,

Response.Write( "<script language=javasc ript>alert('HEY !');</script>);

, pop-up after the page has been posted back? I am pressing a button,
validating data and then wanting to simply pop-up an alert if say the
login is empty. When I click the button though the page is blank but
the pop-up is there.
Nov 15 '05 #1
4 29913
In the postback function, you can use:

[C#]
string strScript = "<script language='JavaS cript'>alert('H ey!')</script>";
Page.RegisterSt artupScript("Po pUp", strScript);

[VB.NET]
Dim strScript As String = "<script
language='JavaS cript'>alert('H ey')</script>"
Page.RegisterSt artupScript("Po pUp", strScript)

However, it might be easier to use the RequiredFieldVa lidator control to
avoid an unecessary round-trip. If you want to have a popup, you could have
your custom javascript function validate the login field, and pop-up an
alert if it is empty, before submitting the form.

Regards,

Mun

"PH" <p_*******@yaho o.com> wrote in message
news:c5******** *************** ***@posting.goo gle.com...
Does anyone know how to have the pop-up javascript alert,

Response.Write( "<script language=javasc ript>alert('HEY !');</script>);

, pop-up after the page has been posted back? I am pressing a button,
validating data and then wanting to simply pop-up an alert if say the
login is empty. When I click the button though the page is blank but
the pop-up is there.

Nov 15 '05 #2
Forms have a client-side event called "onSubmit". You can specify a
JavaScript function that will handle this event and perform client-side
validation before the form is posted back to the server.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"PH" <p_*******@yaho o.com> wrote in message
news:c5******** *************** ***@posting.goo gle.com...
Does anyone know how to have the pop-up javascript alert,

Response.Write( "<script language=javasc ript>alert('HEY !');</script>);

, pop-up after the page has been posted back? I am pressing a button,
validating data and then wanting to simply pop-up an alert if say the
login is empty. When I click the button though the page is blank but
the pop-up is there.


Nov 15 '05 #3
Hi,

I think that the best way of doing this is using client side validation,
this avoid the round trip to the server just to report trivials errors as an
empty login.

Take a look at MSDN for how to use client side validators, it;s very easy.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"PH" <p_*******@yaho o.com> wrote in message
news:c5******** *************** ***@posting.goo gle.com...
Does anyone know how to have the pop-up javascript alert,

Response.Write( "<script language=javasc ript>alert('HEY !');</script>);

, pop-up after the page has been posted back? I am pressing a button,
validating data and then wanting to simply pop-up an alert if say the
login is empty. When I click the button though the page is blank but
the pop-up is there.

Nov 15 '05 #4
For the simple validation you describe below, client side validators and
simple javascript may be sufficient. However, in our case, when we needed to
communicate back from the server to the client via a popup "alert", we wrote
a javascript function to call a standard html page that would become the
popup (so it could inherit the stylesheets and not just be a basic alert
box) and then on the main page, we placed a hidden text control.

The text control was unpopulated the first load. On submit, if no message
was needed, the textbox was still left empty. But if we needed to
communicate back, we populated the textbox with a message string from the
server that the onload() could see a) textbox isn't empty, so I need to
initiate the message popup and b) parse the hidden textbox to pull out the
values. The Javascsript function then opened the window, passing the
appropriate values it got from the textbox in the querystring to the message
page. Voila, customized, stylesheet driven alert boxes.

You can take it a step further and allow the popup to communicate back to
the parent then (for example, you might want an OK and CANCEL) so that the
main page can make some response to the user decision. We standardized
that HTML/Javascript function to give most of the standard responses of a
regular message box (OK only, OK/CANCEL, YES/NO, etc.)

It's a pain in the you know what to get it built and hooked up the first
time, but then it's the same thing over and over again when ever you need
it. Put the javascript in a #include and you won't have to be rewriting that
on each aspx/html page.

Todd

"PH" <p_*******@yaho o.com> wrote in message
news:c5******** *************** ***@posting.goo gle.com...
Does anyone know how to have the pop-up javascript alert,

Response.Write( "<script language=javasc ript>alert('HEY !');</script>);

, pop-up after the page has been posted back? I am pressing a button,
validating data and then wanting to simply pop-up an alert if say the
login is empty. When I click the button though the page is blank but
the pop-up is there.

Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2286
by: TrvlOrm | last post by:
Can any one please help me...I am new to JavaScript and I have been struggling with this code for days now and can't figure it out. I would like to get the Buttons to correspond with the action to either a) generate numbers b) Prompts a user to locate a web page c) go to previous page in history list d) Loads next page in history list e) Promps the user for a URL and loads the web page in a new window f) and Re-Sizes the window. ...
14
5471
by: tshad | last post by:
I posted this on the asp.net group, also. I wasn't sure whether this was an asp.net problem or a javascript problem. I have a page that was originally created from a program I found on the net that works well as an html page. It brings up a modal popup window that I have been trying to work out for days now and this was the closest I have been able to come. I added a little asp.net code and an asp.net button and cannot get it to
15
4221
by: binnyva | last post by:
Hello Everyone, I have just compleated a JavaScript tutorial and publishing the draft(or the beta version, as I like to call it) for review. This is not open to public yet. The Tutorial is avaliable at... http://www.geocities.com/binnyva/code/javascript/advanced_tutorial/ If any of you could spare the time, please have a look at my tutorial
9
4916
by: tshad | last post by:
This is from my previous post, but a different issue. I have the following Javascript routine that opens a popup page, but doesn't seem to work if called from an asp.net button. It seems to work fine from a link. The button does bring up the popup window, but when I press the links on the page, it doesn't return or close the window. ****************************************************************************
13
18681
by: monomaniac21 | last post by:
hi i want to be able to trigger a javascript style popup alert in php (i want a message displayed on the actual page) is this possible?
7
3220
by: julian.tklim | last post by:
Hi, I need to build an editable Datagrid with add & delete buttons on each row using javascript. DataGrid need not be pre-populated with values. To make the thing complicated, one of the column need to be a date picker field. I know things will be easier with ASPX datagrid.
6
2526
by: den 2005 | last post by:
Hi everybody, Question 1: How do you set the values from server-side to a client-side control or how do you execute a javascript function without a button click event? Question 2: How do you get response from a Confirm() popup window to uncheck all server-side checkboxes placed in a panle of a web user control? I am using ASP.Net 2.0, Thanks. Need info...
4
2713
by: =?Utf-8?B?R1ROMTcwNzc3?= | last post by:
Hi Guys, thanks for your help yesterday, I've got one more question, then I think I'm done for now,... Is it possible to insert recordset data in a javascript, for instance I have a javascript code that calculates the total price, depending on number of units, currently what the code does is set the price like so - if qty 1 then £99+VAT if qty equall to or greater than 2 and equall to or less than 9 then price =
0
8583
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9126
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9002
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8861
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7673
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6500
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4588
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3021
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
1984
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.