Hi jchau,
There are several ways:
1. We have very simple control TokenScript. Just it is hidden becuase we are not sure yet useful it or not (may be it should be changed) . I made it public. You can update from the SVN, test it and say useful it or not.
In TokenScript you can use all kind of tokens which are availbale in Listener. iUsage example:
<ext:TokensScript runat="server">
<script type="text/javascript">
add = function(x, y) {
Coolite.AjaxMethods.#{AjaxUC1}.Add(x, y, {
success: function(result) {
alert('Result - ' + result);
},
failure: function(msg) {
alert('Failure - ' + msg);
}
});
}
</script>
</ext:TokensScript>
2. Second way. We added IDMode to the WebControl (also you can set it globally in web.config or ScriptManager). IDMode is enum: Inherit, Legacy, Static. It's a way of controlling what .id is written to the client config.
"Static" will write the .ID.
"Legacy" will write the .ClientID
"Inherit" will inherit from the Parent control.
The default is "Inherit". Give the ability to set a Parent (such as ViewPort) with "Static", then all child controls will inherit the "Static" value.
The clientconfig is much cleaner if using a MasterPage and "Static". Also a list of id's is maintained and an exception thrown if multiple id's are detected.
So, You can set Static IDMode and use ID in js code
3. You can write ClientID in code-behind to js variable and use it js code.
protected void Page_Load()
{
if(!Ext.IsAjaxRequest)
{
ScriptManager1.AddScript("this.myUC1 = '{0}';", this.AjaxUC1.ClientID);
}
}
<script type="text/javascript">
add = function(x, y) {
Coolite.AjaxMethods[myUC1].Add(x, y, {
success: function(result) {
alert('Result - ' + result);
},
failure: function(msg) {
alert('Failure - ' + msg);
}
});
}
</script>