Jul 29, 2009

radTextBox - get the client ID of the TextBox ...

As the radTextBox should be changing its behaviour depending on the mode in which the developer put it. It doesn't return the ID of the TextBox (I mean the input type="text" id) when you call something like:

rtb.ClientID.

So if you have a radTextBox with the name of

rtbName

You will need to say:

string.Format("{0}_text", rtbName.ClientID);

At least I couldn't find a property to return this information for me.
You can also write a simple extension to do the work for you. Something like:


public static string GetTextBoxID(this RadTextBox rtb)
{
return string.Format("{0}_text", rtb.ClientID);
}


So you can then call it like:

rtb.GetTextBoxID();

Hope it helps ...

No comments: