1

I want to use a datetimepicker in aspx page using cs codes.But i have to create it dynamically in cs.I usually use jquery but another solutions can be accepted.

2
  • What have you tried? What's wrong with the first result for 'jquery datepicker' on google? Commented Apr 24, 2012 at 13:00
  • my que "do i use it from code behind ?" Commented Apr 24, 2012 at 13:02

1 Answer 1

3

You can Create the Script dynamically that attaches the jquery script to the control:

string csname1 = "BindDatePickerScript";
Type cstype = this.GetType();

// Get a ClientScriptManager reference from the Page class.
ClientScriptManager cs = Page.ClientScript;
// Check to see if the startup script is already registered.
if (!cs.IsStartupScriptRegistered(cstype, csname1))
{
System.Text.StringBuilder cstext1 = new System.Text.StringBuilder();
cstext1.Append("<script type='text/javascript'>");
cstext1.Append("Your Script");
cstext1.Append("});");
cstext1.Append("</");
cstext1.Append("script>");

cs.RegisterStartupScript(cstype, csname1, cstext1.ToString());
}

This Script gets added at the bottom of the HTML rendered page.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.