This is a migrated thread and some comments may be shown as answers.
radinputmanager, webservice and textchanged
1 Answer 25 Views
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 02 Feb 2011, 11:51 AM
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?

Thanks

1 Answer, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 08 Feb 2011, 02:07 PM
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,
Martin
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.
Tags
Input
Asked by
Chris
Top achievements
Rank 1
Answers by
Martin
Telerik team
Share this question
or