radinputmanager, webservice and textchanged

2 posts, 0 answers
  1. Chris
    Chris avatar
    4 posts
    Member since:
    Dec 2010

    Posted 02 Feb 2011 Link to this post

    I have what on the surface looks like a fairly simple scenario. I have a textbox validated by a radinputmanager via a webservice. This allows the user to enter a produce code. If the code is valid then I want to populate some values with the textboxes textchanged event.

    Heres what I have:

    <asp:TextBox ID="ProductReferenceTextBox" runat="server" Text='<%#Bind("ProductReference") %>' MaxLength="8"
                                AutoPostBack="true" OnTextChanged="ProductReferenceTextBox_TextChanged" />
    <t:RadInputManager ID="MainInputManager" runat="server">
            <t:TextBoxSetting BehaviorID="ProductReferenceBehavior" Validation-Method="ValidateProductCode"
                Validation-Location="ValidationServices/ProductService.asmx" Validation-ValidateOnEvent="All" Validation-IsRequired="true" />
    protected void ProductReferenceTextBox_TextChanged(object Sender, EventArgs E)
    TextBox oSender = (TextBox)Sender;
    if (IocContainer.ProductDao.Exists(oSender.Text))
      Product eProduct = IocContainer.ProductDao.GetProduct(oSender.Text);
        GridDataInsertItem oContainer = (GridDataInsertItem)oSender.NamingContainer;
      Label oLabel = (Label)oContainer.Controls[5].Controls[0];
      oLabel.Text = eProduct.StockUnit;

    This is fine if the code entered is valid, but if the code is invalid (i.e. the webservice validation fails) I don't want to postback to the textchanged event.

    Is there any way to do this?

  2. Martin
    Martin avatar
    833 posts

    Posted 08 Feb 2011 Link to this post

    Hello Chris,

    I am afraid that when the text box AutoPostBack property is set to true, it is impossible to prevent the post back even when validation fails. Instead you should use a separate control which would submit the form. This is the exact approach used in this online example (form is submitted when update button is clicked).

    I hope this helps.

    All the best,
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Back to Top