0

I am working on SharePoint Application pages. I have a SharePoint DropDownChoiceField control on the aspx page. The requirement is to auto populate this control at the time of page load.

  1. Is there a way to call a JavaScript function at any of the events say "onload"?
  2. I am also unable to find this control on the code behind page.

    SharePoint:DropDownChoiceField FieldName="DropDownOptions" ID="ListValue" runat="server">

Thanks

2
  • 1
    Why are you not using ASP.NET Drop down list control instead? You can use _spBodyOnLoadFunctionNames.push("myCustomFunctionName"); to make your JavaScript function run on load. Commented Jun 10, 2014 at 12:54
  • @ArsalanAdamKhatri: Thanks a lot for the help. Could you please write it as answer so that i can mark it as correct. Commented Jun 11, 2014 at 8:03

2 Answers 2

1

Why are you not using ASP.NET Drop down list control instead?

You can use _spBodyOnLoadFunctionNames.push("myCustomFunctionName"); to make your JavaScript function run on load.

1

You can call javascript from code behind as:

Page.ClientScript.RegisterStartupScript(this.GetType(),"CallMyFunction","MyFunction()",true);

where MyFunction() is your javascript function

http://www.codeproject.com/Questions/443131/Call-to-javascript-Function-from-code-behind-using

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.