I have one jquery datepicker control. Using which I want to create one custom ASP.net control.
JQuery datepicker has one property beforeShow. This property is of type function.
In ASP.Net cotrol, I am trying to set the function using string type by JSonItem as follows:
StringBuilder strFunction = new StringBuilder();
strFunction.AppendLine(@"function (input) { ");
strFunction.AppendLine(@" setTimeout(function () { ");
strFunction.Append(@" var buttonPane = $(""#" + ClientID);
strFunction.Append(@""")");
strFunction.AppendLine(@".datepicker(""widget"").find("".ui-datepicker-close"").click(function () {");
strFunction.Append(@" $.datepicker.clearDate($(""#" + ClientID );
strFunction.AppendLine(@"""));");
strFunction.AppendLine(@" });");
strFunction.AppendLine(@" }, 1);");
strFunction.AppendLine("}");
textInput.Call("datepicker", Js.Json(
Js.JsonItem("onSelect", Js.Function(delegate {
if (ValueSelected != null) {
var request = CreateMethodInvocationRequest("OnSelect");
request.Send();
}
})
),
//This is the function type of property
Js.JsonItem("beforeShow",strFunction.ToString())
));
Here but I am not getting the result. Runtime JScript error is getting thrown.If I don’t set beforeShow property then everything works fine. But I need this property. Can anyone suggest other approach?
I solved the problem using one function which returns parses the string into JSExpression.