web forms with client and server side controls??

Hi,

I have a form that has client and server side controls. I have a problem in that
any client controls (textbox) within the form runat="server" can not be accessed
with client side code.
Anyone got any ideas why and what work arounds are possible.
Regards,
Graham.
0
netdocs
11/7/2003 11:43:51 AM
📁 asp.net.client-side
📃 24353 articles.
⭐ 2 followers.

💬 2 Replies
👁️‍🗨️ 1203 Views

once a form element is inside a 
tag, you can no longer refer to it by its ID alone.
you have to refer to it by formname.elementid or document.all.elementid.
0
rox
11/7/2003 3:57:47 PM
use document.getElementById(yourtextboxid) to get a ref to the element in the form.  using this allows u to bypass the formname.  but you must have dom compliant browser like IE.

i use a wrapper function to get objects in my clientside scripting... something like...
////////////////////////////////////////////////
// find an element and return object for it
function getRef(id)
{
try {
return document.getElementById(id);
}
catch (error) {
var sAlert = 'ERROR: fnc {getRef} return the following error: ';
sAlert += '[ ' + error.number + '] - ' + error.description;
alert(sAlert);
}
}
a little bit over the top but saves a lot of typing... J
0
johngilliland
11/12/2003 8:32:17 PM