hi there
i have a page in aspx default.aspx
and im using a control autocomplete.ascx
so when i checked a checkbox in my default.aspx page i want to disabled a requirefield validator in the control autocomplete.ascx,,
but i have no idea how to do that ,
i want to when i checked a checkbox in my default.aspx do something like this
oncheckecd="disblevalidatefield"
function disabledvalidatefield
some code to disabled the required field validator from my other page autocomplete.aspx
disable RequiredFieldValidator1 from autocomplete.ascx
and this is the autocomplete.ascx code
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="Autocomplete.ascx.vb" Inherits="Controls_Autocomplete" %>
<INPUT id="hdnAuto" type="hidden" value="0" name="hdnAuto" runat="server">
<asp:textbox id="txtAutoComplete" runat="server"></asp:textbox><asp:dropdownlist id="txtAutoComplete_Combo" runat="server"></asp:dropdownlist><asp:hyperlink id="hplAutoCompleteWindow" runat="server">
<asp:Image id="imgAutoComplete" runat="server"></asp:Image>
</asp:hyperlink><asp:rangevalidator id="rvAutoComplete_Combo" runat="server" Enabled="False" CssClass="errorBullet"
Type="Integer" MaximumValue="2147483647" MinimumValue="1" Display="Dynamic" ControlToValidate="txtAutoComplete_Combo"
ErrorMessage="="></asp:rangevalidator>
<asp:Label ID="lblScriptReg" runat="server"></asp:Label>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="txtAutoComplete" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>
any help will be really appreciate
many many thanks in advanced
but, how can i access to the requirefieldvalidator??? because im trying to disabled from another aspx page,,
remember im trying to disabled from default.aspx a required field into autocomplete.ascx
please help me, im lost right now
sebastian11c
but, how can i access to the requirefieldvalidator??? because im trying to disabled from another aspx page,,
remember im trying to disabled from default.aspx a required field into autocomplete.ascx
please help me, im lost right now
this should work
ValidatorEnable(document.getElementById("<%=RequiredFieldValidator2.ClientID %>"), false);
this will get the id of control required to access control from usercontrol
hope this helps…
Hi,
Check the below code!
//MyControl.ascx
//--------------------------
<asp:TextBox ID="txtAutoComplete" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1"
runat="server"
ControlToValidate="txtAutoComplete"
ErrorMessage="RequiredFieldValidator">
</asp:RequiredFieldValidator>
//myControl.ascx.cs
//---------------------------
public partial class MyControl : System.Web.UI.UserControl
{
public RequiredFieldValidator CustomRequiredFieldValidator
{
get
{
return RequiredFieldValidator1;
}
set
{
RequiredFieldValidator1 = value;
}
}
}
//Default.aspx
//--------------
<%@ Register Src="~/MyControl.ascx" TagPrefix="uc" TagName="ccontrol" %>
<div>
<uc:ccontrol runat="server" ID="myCustomControl" />
<asp:CheckBox runat="server" Text="Disable Required Field Validator" OnCheckedChanged="Chk_Changed" />
</div>
//Default.aspx
//--------------
protected void Chk_Changed(object sender, EventArgs e)
{
myCustomControl.CustomRequiredFieldValidator.Enabled = false;
}
Hope it helps u…
thanks for your help
many many thanks
i have this default.aspx
<%@ Register Src="../Controls/Autocomplete.ascx" TagName="Autocomplete" TagPrefix="Ultra" %>
<Ultra:Autocomplete ID="acLinea" runat="server" AutoPostBack="false"
EnableViewState="False" ImageUrl="../images/folder_blue.gif" Required="true"
VisibleCombo="false" Width="200" BubbleFunction="fLinea"/>
i use this code in java to disabled the requirefield on my control autocomplete.ascx
ValidatorEnable(document.getElementById("<%=acLinear.ClientID%>_rfvcontrolautocomplete"), false);
and that works
thanks for your time and help
sebastian11c
i have this default.aspx
<%@ Register Src="../Controls/Autocomplete.ascx" TagName="Autocomplete" TagPrefix="Ultra" %>
<Ultra:Autocomplete ID="acLinea" runat="server" AutoPostBack="false"
EnableViewState="False" ImageUrl="../images/folder_blue.gif" Required="true"
VisibleCombo="false" Width="200" BubbleFunction="fLinea"/>
i use this code in java to disabled the requirefield on my control autocomplete.ascx
ValidatorEnable(document.getElementById("<%=acLinear.ClientID%>_rfvcontrolautocomplete"), false);
and that works
thanks for your time and help
Please mark as answer on the posts which helped u. this helps future reader to understand which post resolved the issue