|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Message Box in ASPHello,
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 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 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 > 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 >> > > 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. 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. >
Other interesting topics
Authentication mode in web.config causing crash.
Do i loose the power of asp.net if i use a custom extension (not .aspx) with IHttpHandlerFactory what is Request.ServerVariables how to make VS auto suggest properties during dev Dataview returns 0 rows Newbie on Session State Unable to map the debug start page URL to a machine name User Controls in 2.0 embeding wmp w/instant play?l another ctp? |
|||||||||||||||||||||||