This is a migrated thread and some comments may be shown as answers.

Radbutton posting back without validation

3 Answers 171 Views
Button
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 19 Apr 2013, 12:50 PM
Hi Telerik,

I have a radtextbox, a required field validator and a radbutton on a page.

If I try clicking the radbutton with nothing in the textbox, the validator works and stops the page from posting.

If I then enter something in the text box and submit, it works as expected. I then (in codebehind) clear the text box.

Now, with the empty textbox, I click the button again, it actually does a postback and the postback has to handle the validation, which is not correct. The validator is not firing.

I have put a sample code zip file at http://www.revilloc.com/validate-problem.zip showing the issue. I am using telerik version 2013.1.403.40

Thank you.
David.

3 Answers, 1 is accepted

Sort by
0
Danail Vasilev
Telerik team
answered on 23 Apr 2013, 01:53 PM
Hi David,

Please find below my comments:
  • It is not recommended to use the RadAjaxManager & RadAjaxPanel controls at the same time. More information on this regard is available in Ajaxifying Controls Wrapped in RadAjaxPanel and Added to RadAjaxManager Settings help article.
  • Nesting RadAjaxPanels is not a valid scenario. You can find more information on using RadAjaxPanel here and here.
  • When you ajaxify an asp panel make sure that it is the initiator of the ajax request as well as the control which is to be updated. There is an example on how to do that here.
  • When you load user controls dynamically make sure that they are instantiated on Page_Init or Page_Load and the last loaded User Control is always recreated. You can find useful Load User Controls help article as well as Ajax - Loading User Controls online demo.
  • It is not necessary to make ajax request twice - the first time on pageLoad event and the second time in the code behind.
You can find the modified version of your example with the above changes in the attached archive.

Regards,
Danail Vasilev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
David
Top achievements
Rank 1
answered on 23 Apr 2013, 02:30 PM
Hi Danail,

This doesn't really answer my query.

The sample code is the basics of how our system is set up and I will not be able to undo all of it. I have included all the levels of everything we have in case there is something in the chain that may be causing it.

Unfortunately, your response does not really provide any pointers to resolve the problem, just telling me where the code is not following telerik best practice. As mentioned, unfortunately, the company's software has evolved so much that the "stack" for want of a better word is the best option for us.

So, my problem still exists. How can I ensure that there is not a postback for the second submit?

Thank you.
David.
0
Marin Bratanov
Telerik team
answered on 25 Apr 2013, 03:44 PM
Hello David,
 
This article: http://geekswithblogs.net/ranganh/archive/2007/05/16/112525.aspx will explain the basics of nesting UpdatePanels (which is, essentially, what RadAjax uses). The case here is that we need to trap postbacks and make them partial, which cannot happen with asp:Panel controls, they are not IPostBack controls and there is no way to determine which is the actual control that posted the page, so the end result is an update panel with updateMode=Always. 

This means that the entire pnlControlContainer will be disposed if a control inside performs a postback, so the inner RadAjaxPanels cannot help in containing the postback, they only act as nested update panels that cause issues with updating the content.

I am attaching here the page as I ran it and a video that shows the expected behavior. The pnlControlContainer div will always be updated with any postback and update panels around it or inside it are useless. You can see it by examining the network traffic in detail, in my case I used the network tab to show there are no requests (you can ignore the 404s for the image).
 
Greetings,
Marin Bratanov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Button
Asked by
David
Top achievements
Rank 1
Answers by
Danail Vasilev
Telerik team
David
Top achievements
Rank 1
Marin Bratanov
Telerik team
Share this question
or