Is it possible to fire a JavaScript function on a SharePoint Control in Application pages?
-
28-09-2020 - |
Question
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.
- Is there a way to call a JavaScript function at any of the events say "onload"?
I am also unable to find this control on the code behind page.
SharePoint:DropDownChoiceField FieldName="DropDownOptions" ID="ListValue" runat="server">
Thanks
Solution
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.
OTHER TIPS
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