Home All Groups Group Topic Archive Search About
Author
10 Jun 2005 3:53 PM
Randy
Hello,
I'm trying to figure out how to set up and call a javascript pop up window
within C# ASP. I know how to use RegisterStartupScript. This works fine if I
use it in the Page_Load area. What I want to do is call a pop-up window from
several areas in my class.
For example, I've got a Submit button but based on several conditions I
might want to pop up a message with the message varying. If I put the
RegisterStartupScript in this Submit_Click function, it doesn't pop up
anything.
I'm thinking I need to register a javascript popup function and then call
the function where I need to, but I don't know how to do this.
Can someone point me in the right direction?

Thanks

Author
10 Jun 2005 4:49 PM
Steve C. Orr [MVP, MCSD]
Here are some free MessageBox controls you can use to simplify things.  The
source code is included in case you need to make any modifications:
http://SteveOrr.net/articles/ClientSideSuite.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net


Show quoteHide quote
"Randy" <t***@temp.com> wrote in message
news:O7zieSdbFHA.3464@tk2msftngp13.phx.gbl...
> Hello,
> I'm trying to figure out how to set up and call a javascript pop up window
> within C# ASP. I know how to use RegisterStartupScript. This works fine if
> I use it in the Page_Load area. What I want to do is call a pop-up window
> from several areas in my class.
> For example, I've got a Submit button but based on several conditions I
> might want to pop up a message with the message varying. If I put the
> RegisterStartupScript in this Submit_Click function, it doesn't pop up
> anything.
> I'm thinking I need to register a javascript popup function and then call
> the function where I need to, but I don't know how to do this.
> Can someone point me in the right direction?
>
> Thanks
>
Are all your drivers up to date? click for free checkup

Author
10 Jun 2005 5:28 PM
Randy
That's just what I needed...Thanks so much!



Show quoteHide quote
"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
news:uNDKgxdbFHA.1456@TK2MSFTNGP15.phx.gbl...
> Here are some free MessageBox controls you can use to simplify things.
> The
> source code is included in case you need to make any modifications:
> http://SteveOrr.net/articles/ClientSideSuite.aspx
>
> --
> I hope this helps,
> Steve C. Orr, MCSD, MVP
> http://SteveOrr.net
>
>
> "Randy" <t***@temp.com> wrote in message
> news:O7zieSdbFHA.3464@tk2msftngp13.phx.gbl...
>> Hello,
>> I'm trying to figure out how to set up and call a javascript pop up
>> window within C# ASP. I know how to use RegisterStartupScript. This works
>> fine if I use it in the Page_Load area. What I want to do is call a
>> pop-up window from several areas in my class.
>> For example, I've got a Submit button but based on several conditions I
>> might want to pop up a message with the message varying. If I put the
>> RegisterStartupScript in this Submit_Click function, it doesn't pop up
>> anything.
>> I'm thinking I need to register a javascript popup function and then call
>> the function where I need to, but I don't know how to do this.
>> Can someone point me in the right direction?
>>
>> Thanks
>>
>
>
Author
10 Jun 2005 5:20 PM
Phillip Ian
It is similar to RegisterStartupScript...

    Page.RegisterClientScriptBlock("alertblock", "<script
language='javascript'>function doalert() {alert('Hi there!'); return
true;}</script>")

And to call it from one of your buttons, add this:

    Button1.Attributes.Add("onclick", "javascript:return doalert();")

Note that the return value will determine whether or not your page
posts back.  So if you put return false in the function, you won't get
a postback, but return true will let the button continue on with
whatever server-side functionality it has.
Author
10 Jun 2005 5:54 PM
Randy
What if you want to call it from within a button click function, and put
different messages in it based on certain processing?
How would you call it like this?

Show quoteHide quote
"Phillip Ian" <phl***@comcast.net> wrote in message
news:1118424040.972983.126760@f14g2000cwb.googlegroups.com...
> It is similar to RegisterStartupScript...
>
>    Page.RegisterClientScriptBlock("alertblock", "<script
> language='javascript'>function doalert() {alert('Hi there!'); return
> true;}</script>")
>
> And to call it from one of your buttons, add this:
>
>    Button1.Attributes.Add("onclick", "javascript:return doalert();")
>
> Note that the return value will determine whether or not your page
> posts back.  So if you put return false in the function, you won't get
> a postback, but return true will let the button continue on with
> whatever server-side functionality it has.
>

Bookmark and Share