Conditional Javascript Call

Discussion in 'ASP .Net' started by TCORDON, Nov 8, 2005.

  1. TCORDON

    TCORDON Guest

    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!
    TCORDON, Nov 8, 2005
    #1
    1. Advertising

  2. 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:

    > 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!
    >
    >
    >
    =?Utf-8?B?Q3VydF9DIFtNVlBd?=, Nov 8, 2005
    #2
    1. Advertising

  3. TCORDON

    Mr Newbie Guest

    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" <> wrote in message
    news:e$...
    > 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!
    >
    >
    Mr Newbie, Nov 8, 2005
    #3
  4. I think you are looking for RegisterStartupScript ..

    in your Page_Load()

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

    if(txtMyText.text.Length > 0)
    {
    Page.RegisterStartupScript("somename", jscript );
    }




    "TCORDON" wrote:

    > 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!
    >
    >
    >
    =?Utf-8?B?U3JlZWppdGggUmFt?=, Nov 8, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alec S.
    Replies:
    10
    Views:
    10,082
    Alec S.
    Apr 16, 2005
  2. Replies:
    1
    Views:
    2,723
    Malcolm Dew-Jones
    Apr 5, 2005
  3. bnp
    Replies:
    30
    Views:
    828
    Ralmin
    May 25, 2004
  4. Fabio Mastria
    Replies:
    4
    Views:
    715
    Fabio Mastria
    Jan 28, 2008
  5. Replies:
    2
    Views:
    109
Loading...

Share This Page