Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

Getting the ClientID of ASP.NET server controls in external .js files

$
0
0

Hi,

In the aspx webform, I can put this:

  --- Javascript in ASPX:

function methodCompleted(results, context, methodName) {


            $get("<%=Button1.ClientID%>").disabled = false;
            $get("<%=lblHora.ClientID%>").innerHTML = results.toString();
 }
function getTimeBtnClicked(sender) {
    sender.disabled = true;
    PageMethods.GetTime(methodCompleted);
}

---- HTML in ASPX:
 [WebMethod]
 public static DateTime GetTime()
 {
     return DateTime.Now;
 }


And it works, I mean, I get the clientId of the server controls in runtime.

 

But the same code, in a external .js file, doesn't work.

Question 1
Obviuosly I prefer to have the javascript code on external .js files, it is possible to use <%=%> in a external .js file and execute it as a server side code?

Question 2
Is it possible to pass information of the sender object to the "methodCompleted" callback as a parameter?

 

Thanks!


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>