Alternative for using $find and jquery selector in order to get object in ASP.net application -


i call method of element can returned asp.net sys.application method "$find". in case telerik radwindow control (id="mywindow") , call .show() method.

the problem correct client id of control in separate js file, since ids gets modified in asp.net framework. use

$find($("[id$=mywindow]")[0].id).show(); 

this works if there 1 element on page id ends "mywindow". unfortunately control adds strange wrapper element page id ends "mywindow", too.

so question: there better way asp.net element object in separate js file besides ugly combination of $find , jquery selection?

you write small javascript enclosure @ end of page , add controls wish address in external files needed.

<script> var controls = new function () {     return {         radwinmanagermain: {             clientid: "<%= radwinmanagermain.clientid %>"         },         radwinmanagersub: {             clientid: "<%= radwinmanagersub.clientid %>"         }     }; }(); </script> 

i using 2 separate radwindowmanagers wanted address in external js file. getradwindowmanager() have returned first radwindowmanager instance on page. therefore chose approach.

when calling function (which implemented in external js) pass on reference controls returns ids.

<telerik:navigationnode navigateurl="javascript:showwindow(controls.radwinmanagermain,'winsettings');" value="settings" text="settings" spritecssclass="fa fa-cog" runat="server" /> 

in external js file:

function showwindow(control, windowname) {     $find(control.clientid).open(null, windowname);     more code here... } 

i found idea on: http://www.telerik.com/blogs/simplify-javascript-control-references-in-asp.net-webforms


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -