November Happy Hour will be moved to Thursday December 5th.

Trying to add a HtmlButton in LinkGeneric.aspx

Vote:
 
I am trying to add a HtmlButton i LinkGeneric.aspx (the hyperlink popup for the editor) by creating a shadow file (/edit_/LinkGeneric.aspx) In OnPreRender i locate the UserControl that holds the URL by using TextBox urlControl = (TextBox)control.FindControl("linkUrl"); which is fine. Now I would like to add a HtmlButton next to it, by using control.Controls.Add( new HtmlButton() ); where "control" is the Control that holds the inputcontrols for the linkspace placeholder. I get the runtime error : The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>). Any workarounds for this?
#17330
Dec 17, 2004 11:02
Vote:
 
hmm...no feedback on this one, but I have found a solution for it. I am adding the button in JavaScript instead. Just run a RegisterStartupScript("AddEmailPopupButton", @""); The script adds the button in the same cell as the textfield and after the textfield. function addEmailPopupButton(strNameOfEmailField) { if (document.getElementById) { var objPopupButton = " "; var objEmailTextField = document.getElementById(strNameOfEmailField); objEmailTextField.parentElement.innerHTML = objEmailTextField.parentElement.innerHTML + objPopupButton; } } The reason for the error is because the dynamically added usercontrol for email links has code like this: ]]>> (see Util\LinkGenericMail.ascx) Using ODA is not easy when controls are added dynamically. The shadowfiles can only be used if the file does not load a user control dynamically, like in this example. Maybe the developers at EP should change that ;)
#17987
Jan 10, 2005 11:34
Vote:
 
I'm glad you solved it, and thanks for the input. It can be difficult to predict all cases when you want to modify the controls, but we always try to improve those things. I'll make a note of the suggestion and see what we can do.
#17988
Jan 10, 2005 12:31
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.