asp.net - Client side script not recognized for the usercontrol

Discussion in 'Software' started by sara_23apr, Sep 17, 2006.

  1. sara_23apr

    sara_23apr

    Joined:
    Sep 7, 2006
    Messages:
    3
    Hello Everybody

    I have a date text box im my asp.net page, I am using regular expression validator to enter the date in the format dd-mm-yyyy .

    on blur event of the textbox (i am explicitly calling that onblur event in page load.) i am calling javascript to change the format of date to dd-MMM-yyyy

    (i.e the user enter 01/01/2006....onblur it is changed to 01/Jan/2006)

    This is working fine in page level.

    But I want to create a "user control" for this . I created same thing using user control. But it is not working.

    In load event of the user control , i used this script tag to recognize the javascript.

    Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), "MyScript", "document.getElementById('Me.ChosenDate.ClientID').value = str2", True)

    But it is not working. It does not give error but does not work either :-(


    I also tried to create a .js file and call it in Page load....even this did not help
    Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), "MyScript", "datecode.js", True)

    Please help

    Have a great day ahead
    Regards
    Sara
    sara_23apr, Sep 17, 2006
    #1
    1. Advertising

  2. sara_23apr

    Raja

    Joined:
    Sep 26, 2006
    Messages:
    1
    Dear Sara,

    If ur using Server Controls in the user control then just try this Page.ClientScript.RegisterClientScriptBlock(Me.Get Type(), "MyScript", "document.all['Me.ChosenDate.ClientID').value = str2", True)

    if this doesnot work out

    in the load event of the use control u need to add a attribute "onblure" key to the text box of the user control with the value as javascript function that u used for the first ( "on blur event of the textbox (i am explicitly calling that onblur event in page load.) i am calling javascript to change the format of date to dd-MMM-yyyy ")

    hope u solve ur problem.

    Regards.
    Raja
    Raja, Sep 27, 2006
    #2
    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. binand@gmail.com
    Replies:
    1
    Views:
    646
    Walter Roberson
    Dec 15, 2004
  2. mredelin
    Replies:
    0
    Views:
    1,183
    mredelin
    Dec 20, 2007
  3. Giuen
    Replies:
    0
    Views:
    866
    Giuen
    Sep 12, 2008
  4. Kavitha Shalini
    Replies:
    1
    Views:
    472
    Hermit Dave
    Jan 17, 2004
  5. Apolta
    Replies:
    0
    Views:
    990
    Apolta
    Jun 9, 2009
Loading...

Share This Page