Client side script not recognized for the usercontrol
Client side script not recognized for the usercontrol
Client side script not recognized for the usercontrol
Client side script not recognized for the usercontrol
Client side script not recognized for the usercontrol
Client side script not recognized for the usercontrol Client side script not recognized for the usercontrol Client side script not recognized for the usercontrol Client side script not recognized for the usercontrol Client side script not recognized for the usercontrol Client side script not recognized for the usercontrol Client side script not recognized for the usercontrol Client side script not recognized for the usercontrol
Client side script not recognized for the usercontrol Client side script not recognized for the usercontrol
Client side script not recognized for the usercontrol
Go Back  Xtreme Visual Basic Talk > > > Client side script not recognized for the usercontrol


Reply
 
Thread Tools Display Modes
  #1  
Old 09-16-2006, 09:33 PM
sara23apr sara23apr is offline
Newcomer
 
Join Date: May 2006
Posts: 23
Default Client side script not recognized for the usercontrol


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

Regards
Sara
Reply With Quote
  #2  
Old 09-17-2006, 08:05 PM
wayneph's Avatar
waynephClient side script not recognized for the usercontrol wayneph is offline
Web Junkie

Retired Moderator
* Expert *
 
Join Date: Apr 2004
Location: D/FW, Texas, USA
Posts: 8,393
Default

at a minimum you're going to have to change the string with the ClientID.

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

Other than that, how is this script going to get called? This looks like it will just change it the first time the page is loaded. If the user changes it while working on the control, it won't change until it makes a round trip to the server.
__________________
-- wayne, MSSM Retired
> SELECT * FROM users WHERE clue > 0
0 rows returned
Reply With Quote
  #3  
Old 09-17-2006, 09:01 PM
sara23apr sara23apr is offline
Newcomer
 
Join Date: May 2006
Posts: 23
Default pls help

Quote:
Originally Posted by wayneph
at a minimum you're going to have to change the string with the ClientID.

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

Other than that, how is this script going to get called? This looks like it will just change it the first time the page is loaded. If the user changes it while working on the control, it won't change until it makes a round trip to the server.
Thanks for the reply

I am prety new to asp.net
Please help me as to how to write the code so that it works without the round trip to server....i need it to be handled in the client.

Thanks for your time
"Have a great day"

Sara
Reply With Quote
  #4  
Old 09-18-2006, 07:41 AM
wayneph's Avatar
waynephClient side script not recognized for the usercontrol wayneph is offline
Web Junkie

Retired Moderator
* Expert *
 
Join Date: Apr 2004
Location: D/FW, Texas, USA
Posts: 8,393
Default

I'd add it as an attribute on the control.

Me.ChosenDate.Attributes.Add("onblur", "myJavaScriptFunction(this);")

Then on your page, I'd have a Javascript function that does what you need to do:

HTML Code:
<script type="text/javascript">
/* <![CDATA[ */
function myJavascriptFunction(tBox) {
  myDate = tBox.value;
  //work with myDate here and format it the way you want
  //Then set the value back to the textbox.
  tBox.value = myFormattedDate;
}
/* ]]> */
</script>
Even if you have multiple controls on your form, they can all share the same function. By passing in the javascript "this" object, tBox in the function is automatically pointing to the correct instance of your text box.
__________________
-- wayne, MSSM Retired
> SELECT * FROM users WHERE clue > 0
0 rows returned
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Client side script not recognized for the usercontrol
Client side script not recognized for the usercontrol
Client side script not recognized for the usercontrol Client side script not recognized for the usercontrol
Client side script not recognized for the usercontrol
Client side script not recognized for the usercontrol
Client side script not recognized for the usercontrol Client side script not recognized for the usercontrol Client side script not recognized for the usercontrol Client side script not recognized for the usercontrol Client side script not recognized for the usercontrol Client side script not recognized for the usercontrol Client side script not recognized for the usercontrol
Client side script not recognized for the usercontrol
Client side script not recognized for the usercontrol
 
Client side script not recognized for the usercontrol
Client side script not recognized for the usercontrol
 
-->