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_onchange(this);">
......
</select>
and the script handler function is like below:
function lst_onchange(lst)
{
// 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="handlechange();" >
<option title="item1" value="item1">item1</option>
<option title="item2" value="item2">item2</option>
<option title="item3" value="item3">item3</option>
</select>
================
==========code behind=======
protected void Page_Load(object sender, EventArgs e)
{
string script = @"
<script language='javascript'>
function handlechange()
{
var lst = document.getElementById('lstid');
alert(lst.selectedIndex);
}
</script>
";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(),
"lst_onchange",
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.)