Hi Alex,
For client-side html element's event handler, you can pass the additional
reference to the element itself to the handler function. For example,
suppose we have the following html select list,
<select id="lst" runat="server" onchange="lst_o nchange(this);" >
......
</select>
and the script handler function is like below:
function lst_onchange(ls t)
{
// use lst to reference the select element directly
}
Thus, we even do not need to care about the actual client-side ID of the
rendered select html element.
BTW, for control whose clientside ID will be mangled, we can use its
"ClientID" server-side property to get its client-side(managled).
For example, for the above instance, we use a non-parameter handler
function, and register it dynamically in codebehind so that we can output
the correct client-side of the select list:
=======aspx==== ========
<select id="lst" runat="server" onchange="handl echange();" >
<option title="item1" value="item1">i tem1</option>
<option title="item2" value="item2">i tem2</option>
<option title="item3" value="item3">i tem3</option>
</select>
=============== =
==========code behind=======
protected void Page_Load(objec t sender, EventArgs e)
{
string script = @"
<script language='javas cript'>
function handlechange()
{
var lst = document.getEle mentById('lstid ');
alert(lst.selec tedIndex);
}
</script>
";
Page.ClientScri pt.RegisterClie ntScriptBlock(t his.GetType(),
"lst_onchan ge",
script.Replace( "lstid", lst.ClientID)
);
}
=============== =============
Hope this helps.
Regards,
Steven Cheng
Microsoft Online Community Support
=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)