Question ValidatorCalloutExtender Problem in code behind?

raysefo

Well-known member
Joined
Jul 21, 2010
Messages
207
Programming Experience
Beginner
Hi,

I m trying to add ValidatorCalloutExtender in code behind but getting this error "Unable to find control id 'ctl00_ContentPlaceHolder2_TextBox_firmaunvani' referenced by the 'ControlToValidate' property of 'r_TextBox_firmaunvani'."

Any help please?

Thanks in advance

Best Regards

Here is the code

html
HTML:
<asp:UpdatePanel runat="server" ID="UpdatePanel2">
                        <ContentTemplate>
                            <asp:TextBox runat="server" ID="TextBox_firmaunvani" Text=""></asp:TextBox>
                            <asp:Button ID="Button1" runat="server" Text="<%$ Resources:OdemeTalep, Button1 %>"
                                CausesValidation="False" />
                        </ContentTemplate>
                    </asp:UpdatePanel>

and vb
VB.NET:
If String.IsNullOrEmpty(TextBox_firmaunvani.Text) Then
            Dim v_VCALLOUT As New AjaxControlToolkit.ValidatorCalloutExtender
            Dim r_VALIDATOR As New System.Web.UI.WebControls.RequiredFieldValidator

            With r_VALIDATOR
                .ID = "r_" & TextBox_firmaunvani.ID
                .ControlToValidate = "ctl00_ContentPlaceHolder2_" + TextBox_firmaunvani.ID
                .Display = ValidatorDisplay.None
                .Font.Name = "Verdana"
                .Font.Size = FontSize.XSmall
            End With
            Me.Page.Controls.Add(r_VALIDATOR)
            With v_VCALLOUT
                .ID = "v_" & r_VALIDATOR.ID
                .Width = New Unit(200)
                .HighlightCssClass = "highlight"
                .WarningIconImageUrl = "~/images/warning.gif"
                .CloseImageUrl = "~/images/close.gif"
                .TargetControlID = r_VALIDATOR.ID
                .Enabled = True
            End With

           
            Select Case Thread.CurrentThread.CurrentCulture.Name
                Case "tr-TR"
                    With r_VALIDATOR
                        .ErrorMessage = " Firma Ünvanı Girip Getir Düğmesine Basın!"
                    End With
                  
                Case "en-US"
                    With r_VALIDATOR
                        .ErrorMessage = " Enter Company Name and Press Find Button!"
                    End With
                    
            End Select

            Me.Page.Controls.Add(v_VCALLOUT)
            TextBox_firmaunvani.Focus()


            Exit Sub
        End If
 
Still getting error
Unable to find control id 'ctl00_ContentPlaceHolder2_TextBox_firmaunvani' referenced by the 'ControlToValidate' property of 'r_TextBox_firmaunvani'.
 
Now i added Required Field Validator to aspx. Here is the aspx page

....

<asp:UpdatePanel runat="server" ID="UpdatePanel2">
<ContentTemplate>
<asp:TextBox runat="server" ID="TextBox_firmaunvani" Text=""></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="<%$ Resources:OdemeTalep, Button1 %>"
CausesValidation="False" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox_firmaunvani"
ErrorMessage="<%$ Resources:OdemeTalep, RequiredFieldValidator1 %>" Text='<img src="Images/validation_error.png">'
Font-Bold="True" SetFocusOnError="True" Display="None"></asp:RequiredFieldValidator>
<asp:Label ID="lblPopupTargetID" runat="server" Style="display: none;"></asp:Label>



And the vb code is

If String.IsNullOrEmpty(TextBox_firmaunvani.Text) Then
Dim v_VCALLOUT As New AjaxControlToolkit.ValidatorCalloutExtender
With v_VCALLOUT
.ID = "ValidatorCalloutExtender20"
.Width = New Unit(200)
.HighlightCssClass = "highlight"
.TargetControlID = RequiredFieldValidator1.ID
.Enabled = True
End With


Me.Page.Controls.Add(v_VCALLOUT)
TextBox_firmaunvani.Focus()

Exit Sub
End If


This time there is NO error but ValidatorCalloutExtender DOES NOT pops up???

Any ideas?


Best Regards..
 
Back
Top