开发者

JQUERY DatePicker plugin used with usercontrols --> ASP.NET...?

开发者 https://www.devze.com 2023-01-06 12:42 出处:网络
can i use jquery date picker with usercontrol of ASP.Ne开发者_StackOverflow社区t..?/ i tried but its not working - but i tried with Default.aspx page, its working normal ??

can i use jquery date picker with usercontrol of ASP.Ne开发者_StackOverflow社区t..?/

i tried but its not working - but i tried with Default.aspx page, its working normal ??

wat should i do to use with Usercontrol.??


I would use an external .js file for this, and remove the reliance on IDs or names (which ASP.Net will screw with, in < 4.0 anyway), like this:

In your userControl:

<asp:TextBox ID="anything" CssClass="datepicker" />

In your .js file, use a class selector instead of the ID, like this:

$(".datepicker").datepicker();

Using a class means one set of code for any number of these datepickers in the page and you don't have to worry about what the IDs are going to look like in the page...they just won't be used for this.


JQuery controls are fully client side. This means that after the server processes the UserControl, adding it into the Default.aspx page, then the client will just see a single html page with the jQuery markup included.

So in short, yes the jQuery will work with userControls as long as the UserControl is added properly into the page.


Without seeing the code, the best guess I have is that your control's ID isn't correct. Remember that ASP.NET, if you have a server control inside of a user control (or other container-type objects), then the ID that shows up on the page isn't what you put in your markup, but rather a generated unique ID.

So if you're using an <asp:TextBox>, then make sure you're putting the full ID in your javascript, like:

$("#<%= myTextBox.ClientID %>").datepicker();


Rick Strahl made an ASP.Net control basedon the jQuery date picker. You can grab it here

0

精彩评论

暂无评论...
验证码 换一张
取 消