Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Javascript alert

Reply
Thread Tools

Javascript alert

 
 
Peter
Guest
Posts: n/a
 
      11-07-2008
I need a popup alert after a post back.

1) user clicks on the submit button
2) Server side code runs and if the result is false I want to display a java
script alert("It did not work")

How to do I display a popup message after a postback ?

Thank You


Peter


 
Reply With Quote
 
 
 
 
Allen Chen [MSFT]
Guest
Posts: n/a
 
      11-07-2008
Hi Peter,

You can try this:

protected void Button1_Click(object sender, EventArgs e)
{
RegisterClientScriptBlock("test", "<script
type='text/javascript'>alert('hello world!')</script>");
}

Please let me know if it works.

Regards,
Allen Chen
Microsoft Online Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
http://www.velocityreviews.com/forums/(E-Mail Removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subs.../aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| From: "Peter" <(E-Mail Removed)>
| Subject: Javascript alert
| Date: Thu, 6 Nov 2008 22:09:59 -0600
| Lines: 14
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
| X-RFC2646: Format=Flowed; Original
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
| Message-ID: <(E-Mail Removed)>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: cpe-72-129-145-58.new.res.rr.com 72.129.145.58
| Path: TK2MSFTNGHUB02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSF TNGP05.phx.gbl
| Xref: TK2MSFTNGHUB02.phx.gbl
microsoft.public.dotnet.framework.aspnet:79400
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| I need a popup alert after a post back.
|
| 1) user clicks on the submit button
| 2) Server side code runs and if the result is false I want to display a
java
| script alert("It did not work")
|
| How to do I display a popup message after a postback ?
|
| Thank You
|
|
| Peter
|
|
|

 
Reply With Quote
 
 
 
 
George
Guest
Posts: n/a
 
      11-07-2008
Try to use
this.Page.ClientScript.RegisterStartupScript

I recal it works with AJAX.

George.

"Peter" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I need a popup alert after a post back.
>
> 1) user clicks on the submit button
> 2) Server side code runs and if the result is false I want to display a
> java script alert("It did not work")
>
> How to do I display a popup message after a postback ?
>
> Thank You
>
>
> Peter
>
>


 
Reply With Quote
 
Peter
Guest
Posts: n/a
 
      11-07-2008

"George" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Try to use
> this.Page.ClientScript.RegisterStartupScript
>
> I recal it works with AJAX.
>
> George.
>
> "Peter" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>I need a popup alert after a post back.
>>
>> 1) user clicks on the submit button
>> 2) Server side code runs and if the result is false I want to display a
>> java script alert("It did not work")
>>
>> How to do I display a popup message after a postback ?
>>
>> Thank You
>>
>>
>> Peter
>>
>>

>


I've tried that already, nothing happens.


 
Reply With Quote
 
Peter
Guest
Posts: n/a
 
      11-07-2008

"Allen Chen [MSFT]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi Peter,
>
> You can try this:
>
> protected void Button1_Click(object sender, EventArgs e)
> {
> RegisterClientScriptBlock("test", "<script
> type='text/javascript'>alert('hello world!')</script>");
> }
>
> Please let me know if it works.
>
> Regards,
> Allen Chen
> Microsoft Online Support
>
> Delighting our customers is our #1 priority. We welcome your comments and
> suggestions about how we can improve the support we provide to you. Please
> feel free to let my manager know what you think of the level of service
> provided. You can send feedback directly to my manager at:
> (E-Mail Removed).
>
> ==================================================
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/en-us/subs...#notifications.
>
> Note: MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 2 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions. Issues of this
> nature are best handled working with a dedicated Microsoft Support
> Engineer
> by contacting Microsoft Customer Support Services (CSS) at
> http://msdn.microsoft.com/en-us/subs.../aa948874.aspx
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
> --------------------
> | From: "Peter" <(E-Mail Removed)>
> | Subject: Javascript alert
> | Date: Thu, 6 Nov 2008 22:09:59 -0600
> | Lines: 14
> | X-Priority: 3
> | X-MSMail-Priority: Normal
> | X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
> | X-RFC2646: Format=Flowed; Original
> | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
> | Message-ID: <(E-Mail Removed)>
> | Newsgroups: microsoft.public.dotnet.framework.aspnet
> | NNTP-Posting-Host: cpe-72-129-145-58.new.res.rr.com 72.129.145.58
> | Path: TK2MSFTNGHUB02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSF TNGP05.phx.gbl
> | Xref: TK2MSFTNGHUB02.phx.gbl
> microsoft.public.dotnet.framework.aspnet:79400
> | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
> |
> | I need a popup alert after a post back.
> |
> | 1) user clicks on the submit button
> | 2) Server side code runs and if the result is false I want to display a
> java
> | script alert("It did not work")
> |
> | How to do I display a popup message after a postback ?
> |
> | Thank You
> |
> |
> | Peter
> |
> |
> |
>


No that does not work, I get no errors and no PopUp. If I put a break point
at the RegisterClientScriptBlock the process does stop there.


 
Reply With Quote
 
Peter
Guest
Posts: n/a
 
      11-07-2008

"Mark Rae [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Peter" <(E-Mail Removed)> wrote in message
> news:uc$(E-Mail Removed)...
>
>>>>I need a popup alert after a post back.
>>>>
>>>> 1) user clicks on the submit button
>>>> 2) Server side code runs and if the result is false I want to display a
>>>> java script alert("It did not work")
>>>>
>>>> How to do I display a popup message after a postback ?
>>>
>>> Try to use this.Page.ClientScript.RegisterStartupScript

>>
>> I've tried that already, nothing happens.

>
> George's response is correct. Do you have something like this...?
>
> protected void MyButton_Click(object sender, System.EventArgs e)
> {
> bool blnResult = <do server-side processing>;
>
> if (!blnResult)
> {
> ClientScript.RegisterStartupScript(GetType(), "failure", "alert('It
> did not work');", true);
> }
> }
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net


The popup does not work even if you have

if (1==1)
{
ClientScript.RegisterStartupScript(GetType(), "failure", "alert('It
did not work');", true);
}


if I add 'ClientScript.RegisterStartupScript(GetType(), "failure",
"alert('It did not work');", true);' in the Page_Load event it pops up only
when the page loads it never displays on PostBack

protected void Page_Load(object sender, EventArgs e)

{

ClientScript.RegisterStartupScript(GetType(), "failure", "alert('It did
not work');", true);

}


 
Reply With Quote
 
Vinay Khaitan
Guest
Posts: n/a
 
      11-07-2008
uh....simply create a literal control in the end.
when you want to popup, change its text property to something like this.

LiteralControl1.Text = "<script type='text/javascript'>window.open("it works
finally!")</script>"

There are really so many ways to get javascript work in asp.net!
I could even use Header and added an htmlgenericcontrol with similar text.


--
Vinay Khaitan
[Windows Forms Layout Control]
http://www.smart-components.com/
----------------------------------------------------------------


"Peter" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> "Mark Rae [MVP]" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> "Peter" <(E-Mail Removed)> wrote in message
>> news:uc$(E-Mail Removed)...
>>
>>>>>I need a popup alert after a post back.
>>>>>
>>>>> 1) user clicks on the submit button
>>>>> 2) Server side code runs and if the result is false I want to display
>>>>> a java script alert("It did not work")
>>>>>
>>>>> How to do I display a popup message after a postback ?
>>>>
>>>> Try to use this.Page.ClientScript.RegisterStartupScript
>>>
>>> I've tried that already, nothing happens.

>>
>> George's response is correct. Do you have something like this...?
>>
>> protected void MyButton_Click(object sender, System.EventArgs e)
>> {
>> bool blnResult = <do server-side processing>;
>>
>> if (!blnResult)
>> {
>> ClientScript.RegisterStartupScript(GetType(), "failure",
>> "alert('It did not work');", true);
>> }
>> }
>>
>>
>> --
>> Mark Rae
>> ASP.NET MVP
>> http://www.markrae.net

>
> The popup does not work even if you have
>
> if (1==1)
> {
> ClientScript.RegisterStartupScript(GetType(), "failure", "alert('It
> did not work');", true);
> }
>
>
> if I add 'ClientScript.RegisterStartupScript(GetType(), "failure",
> "alert('It did not work');", true);' in the Page_Load event it pops up
> only when the page loads it never displays on PostBack
>
> protected void Page_Load(object sender, EventArgs e)
>
> {
>
> ClientScript.RegisterStartupScript(GetType(), "failure", "alert('It did
> not work');", true);
>
> }
>
>



 
Reply With Quote
 
Peter
Guest
Posts: n/a
 
      11-07-2008

"Mark Rae [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Peter" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
>> if I add 'ClientScript.RegisterStartupScript(GetType(), "failure",
>> "alert('It did not work');", true);' in the Page_Load event it pops up
>> only when the page loads it never displays on PostBack

>
> See my previous reply..
>
> You've got the code in the wrong place - it needs to go in the button's
> OnClick (or OnCommand) event, not the Page_Load event...
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net


It's in OnClick event and it does not work, besides in Page_Load event,
I removed it from Page_Load event and still does not work.


 
Reply With Quote
 
Peter
Guest
Posts: n/a
 
      11-07-2008

"Mark Rae [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Peter" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>
>> It's in OnClick event and it does not work, besides in Page_Load event,
>> I removed it from Page_Load event and still does not work.

>
> Hmm - OK, please show the entire contents of the OnClick event...
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net


here's the code:

protected void butReport_Click(object sender, EventArgs e)
{

ClientScript.RegisterStartupScript(GetType(), "failure", "alert('It
did not work');", true);

}


 
Reply With Quote
 
Peter
Guest
Posts: n/a
 
      11-07-2008

"Mark Rae [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Peter" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
>> here's the code:
>>
>> protected void butReport_Click(object sender, EventArgs e)
>> {
>>
>> ClientScript.RegisterStartupScript(GetType(), "failure",
>> "alert('It did not work');", true);
>>
>> }

>
> Are you sure that it's actually being called? If you put a breakpoint on
> it and click the button, does execution stop on the above line...?
>
>
>

--


Yes, the execution does stop on the line
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Alert..General Alert?..New Discovery?. =?Utf-8?B?U3BhbW1lcipLaWxsZXI=?= Wireless Networking 0 07-24-2007 03:36 PM
on click in popup window throws alert : need to avoid alert of postdata Ganesh ASP .Net 0 06-29-2007 06:51 AM
How to create a form Alert - Not using Alert Boxes Mersh Java 0 03-13-2007 04:14 PM
Detect whether javascript threw an alert window (with javascript) umdsasha@gmail.com Javascript 3 08-24-2006 06:25 AM
ALERT: Virus Scam Alert! Toronto Garage Door Company Computer Support 1 11-18-2003 04:16 PM



Advertisments