The IDs get generated by ASP.NET automatically. I'd probably suggest adding a class to your control and targeting it that way instead. Otherwise, look into ClientIdMode - set this to Static to tell ASP.NET not to touch the ID of that control.
If you don't know where to set the clientid setting in the user control you can set it in the web.config file as Scott shows in the article and then you will see a nice static id.
You can also set it on a usercontrol level in the directive at the top, or in the web.config where it will take effect on all controls. I'd probably reccomend doing the attribute as shown above or just using a class to target instead.
how to get the element id in Marco.
Hi all
I need to create a wyswyg editor in my macro, but when i put it on frontend, the element id changes, so i can not taegeting the textarea box,
<textarea name="ctl00$ctl00$ctl00$ContentPlaceHolderDefault$cp_content$TinyEditor_3$editing" rows="2" cols="20" id="ContentPlaceHolderDefault_cp_content_TinyEditor_3_editing" style="width: 800px; height: 400px"></textarea>
how Name and id generated?
and
how can i get the element id? i need to run javascript on it.
Hi,
The IDs get generated by ASP.NET automatically. I'd probably suggest adding a class to your control and targeting it that way instead. Otherwise, look into ClientIdMode - set this to Static to tell ASP.NET not to touch the ID of that control.
Hope this helps,
Tom
Thank you, so there is no build in class in umbraco for it ?
can i using somthing like umbraco.library.GetXmlNodeCurrent()(or content node)+current macro name + macro Id + real id
to make my own?
Note: I don't know much about umbraco api.
any where good to start?
Hi Jerry
No, there is no built in class in Umbraco that let's you control the rendered id on the elements. It's purely a webforms thing in .net.
You don't need to make a special combination of some Umbraco things to get a nice id in your case. As Tom says you should simply use the clientid attribute in asp.net - as a supplement to Tom's link you can read this article by Scott Gu where he shows how the client id can be set in different circumstances http://weblogs.asp.net/scottgu/archive/2010/03/30/cleaner-html-markup-with-asp-net-4-web-forms-client-ids-vs-2010-and-net-4-0-series.aspx
If you don't know where to set the clientid setting in the user control you can set it in the web.config file as Scott shows in the article and then you will see a nice static id.
Hope this helps.
/Jan
Yup, as Jan said there's nothing umbraco-specific going on here, this is all standard .NET stuff.
You can set the attribute like this:
You can also set it on a usercontrol level in the directive at the top, or in the web.config where it will take effect on all controls. I'd probably reccomend doing the attribute as shown above or just using a class to target instead.
-Tom
is working on a reply...