Web user control and ASPX page

Asked By Girish Barje
09-Sep-10 03:47 AM
Earn up to 30 extra points for answering this tough question.
Hi

I am using webusercontrol with myuc1.ascx. User control has Textbox and the check box. When focus of the text box is changes or onblur checkbox should get enable or disable. I am using the following code in the .ascx page

<%@ Control Language="VB" AutoEventWireup="false" CodeFile="MyVBUC.ascx.vb" Inherits="MyVBUC" %>

<asp:Panel ID="Panel1" runat="server" Height="172px" Width="517px">

<asp:TextBox ID="txtName" runat="server"></asp:TextBox>

<%--<asp:RequiredFieldValidator id="RequiredFieldValidator1" runat="server" ErrorMessage="Required!" ControlToValidate="txtName" ValidationGroup="ABC"></asp:RequiredFieldValidator>--%>

<br /><br />

<asp:CheckBox ID="chkTest" runat="server" />

</asp:Panel>

<script language="javascript" type="text/javascript">

function checkEmpty()

{

if (document.getElementById('<%=txtName.ClientID%>').value == '')

{

document.getElementById('<%=chkTest.ClientID%>').checked = true;

alert('Enter name');

document.getElementById('<%=txtName.ClientID%>').focus();

return false;

}

else

{

document.getElementById('<%=chkTest.ClientID%>').checked = true;

}

}

</script>



and registreted the event of onblur in codebehind as

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

txtName.Attributes.Add("onblur", "javascript:checkEmpty()")

End Sub


This is working fine but in main application I am adding .ascx to my Mainpage.aspx which gives me jquery error with object expected. Could some give thoughts on the same.
Create New Account