This is a migrated thread and some comments may be shown as answers.

controltovalidate is null JS Error

0 Answers 120 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Jonathan
Top achievements
Rank 1
Jonathan asked on 06 Dec 2011, 04:20 PM
Hi

We are using a RadEditor on one of our pages and within this page we have a RequiredFieldValidator that checks if this editor contains any text. If it does not a message is displayed to the user for them to enter text.

We are currently having a problem when a postback occurs. We have an add files link on the page, which popups a new dialog. Once the user has finished with this page we postback that file data to a grid on the page. This then causes a javascript error to appear:

Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET CLR 1.1.4322; .NET4.0C; .NET4.0E; InfoPath.3)
Timestamp: Tue, 6 Dec 2011 15:18:04 UTC

Message: Unable to set value of the property 'controltovalidate': object is null or undefined
Line: 197
Char: 1
Code: 0
URI: https://localhost/3G3/TasksAndDiscussions/Item/TaskOrDiscusionItemFormPage.aspx?HostWindow=POPUP&HostWindowContextContainerID=bc80ecd4-4957-43e5-8e7a-347480972599&HostWindowContextContainerType=TASKFOLDER&HostWindowContextContainerPath=SYSTEM+%2f+4p+Jonathan+Testing+%2f+Site+01+%2f+Project+01+%2f+Tasks&EditMode=NEW&LayoutMode=FILL&NextURL=&HeaderId=bc80ecd4-4957-43e5-8e7a-347480972599&HeaderType=TASK&SpecialAction=NONE&AttachmentsSessionID=00000000-0000-0000-0000-000000000000&mode=popup&openerid=

I believe this is relating to the RequiredFieldValidator checking if any text exists in the RadEditor and it is failing to find the RadEditor on the page.

Below is an example of the code:


<table border=0 width="100%">
	<tr>
		<td valign="top">
			<gen:Field id="cBodyText" runat="server" type="extended" name="Body Text" description="Thread body text" inputdescription="Thread body text"></gen:Field>
		</td>
	</tr>
	<tr>
		<td align="center">
			<radE:RadEditor id="cBodyTextRadEditor" Runat="server" 
				ToolsFile="~/Properties/Content/TasksAndDiscussions/Threaded/TextEditorToolsConfig.xml" 
				Editable="true" height="400px" width="500px" showsubmitcancelbuttons="false" 
				Scheme="~/RadControls/Editor/Schemes/Monochrome" OnClientLoad="OnClientLoad"
				EnableDocking="false" OnClientModeChange="OnClientModeChange"></radE:RadEditor>
		</td>
	</tr>
	<tr>
        <td align="center">
            <asp:label id="lblBodyTextValidation" runat="server" visible="false" style="colorred;" text="The message body is required, please complete your post before proceeding." />
		</td>
    </tr>
    <tr>
		<td align="center">
			<asp:RequiredFieldValidator id="ReqFieldValidator" runat="server" ErrorMessage="The message body is required, please complete your post before proceeding."></asp:RequiredFieldValidator>
		</td>
	</tr>
</table>

protected void Page_Load(object sender, System.EventArgs e)
		{
			if(!IsPostBack)
			{
				if(ReqFieldValidator!=null)ReqFieldValidator.ErrorMessage = resourceManager.GetString("themessagebodyi");
				if(cBodyText!=null)cBodyText.Description = resourceManager.GetString("threadbodytext");
				if(cBodyText!=null)cBodyText.InputDescription = resourceManager.GetString("threadbodytext");
				if(cBodyText!=null)cBodyText.Name = resourceManager.GetString("bodytext");
			}
 
			if (cBodyTextRadEditor.Text == "")
			{
				ReqFieldValidator.ControlToValidate = "cBodyTextRadEditor";
			}
}

No answers yet. Maybe you can help?

Tags
Editor
Asked by
Jonathan
Top achievements
Rank 1
Share this question
or