Conditional Javascript Call

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • TCORDON

    Conditional Javascript Call

    Is there a way to conditionally call a Javascript when a Page loads, say: if
    txtMyText.text <> string.empty then <Javascript>? Or should it all be calles
    using Javascript?

    TIA!


  • Curt_C [MVP]

    #2
    RE: Conditional Javascript Call

    You can, but since this is on PostBack you could easily check this clientside
    before the PostBack occurs...
    If you are trying to so some sort of validation then I would do it will all
    Javascript and stop the PostBack from occuring at all....

    --
    Curt Christianson
    site: http://www.darkfalz.com
    blog: http://blog.darkfalz.com



    "TCORDON" wrote:
    [color=blue]
    > Is there a way to conditionally call a Javascript when a Page loads, say: if
    > txtMyText.text <> string.empty then <Javascript>? Or should it all be calles
    > using Javascript?
    >
    > TIA!
    >
    >
    >[/color]

    Comment

    • Mr Newbie

      #3
      Re: Conditional Javascript Call

      I'm confused by your question.

      When the page loads server side, why would you want to call Javascript from
      code behind ??

      --
      Best Regards

      The Inimitable Mr Newbie º¿º
      "TCORDON" <tcordonb@hotma il.com> wrote in message
      news:e$C4zdI5FH A.3908@tk2msftn gp13.phx.gbl...[color=blue]
      > Is there a way to conditionally call a Javascript when a Page loads, say:
      > if txtMyText.text <> string.empty then <Javascript>? Or should it all be
      > calles using Javascript?
      >
      > TIA!
      >
      >[/color]


      Comment

      • Sreejith Ram

        #4
        RE: Conditional Javascript Call

        I think you are looking for RegisterStartup Script ..

        in your Page_Load()

        string jscript = "<script>alert( "1234");</script>";

        if(txtMyText.te xt.Length > 0)
        {
        Page.RegisterSt artupScript("so mename", jscript );
        }




        "TCORDON" wrote:
        [color=blue]
        > Is there a way to conditionally call a Javascript when a Page loads, say: if
        > txtMyText.text <> string.empty then <Javascript>? Or should it all be calles
        > using Javascript?
        >
        > TIA!
        >
        >
        >[/color]

        Comment

        Working...