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

[Solved] AjaxManager with RangeValidators

2 Answers 107 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Ahmed
Top achievements
Rank 1
Ahmed asked on 14 Jun 2009, 04:19 PM

During our work, we faced some strange problem that occured when having to use a RangeValidator within an Ajaxified Panel.

The scenario is as following

In the next example, All i was trying to do is to modify the MaximumValue property of the RangeValidator based on a values extracted from a TextBox. This means that the MaximumValue is a variant.

The ASPX Code is as following:

<html xmlns="http://www.w3.org/1999/xhtml" > 
<head runat="server">  
    <title></title>  
</head> 
<body> 
    <form id="form1" runat="server">  
    <div> 
        <rad:RadScriptManager ID = "scr" runat = "server" /> 
        <asp:Panel ID = "pnl" runat = "server" > 
        <asp:TextBox ID = "txt1" runat = "server" AutoPostBack = "true" OnTextChanged = "txt1_TextChanged"/>  
        <asp:TextBox ID = "txt2" runat = "server" /> 
        <asp:RequiredFieldValidator ID = "rf" runat = "server" ControlToValidate = "txt2" ValidationGroup = "a" /> 
        <asp:RangeValidator ID = "rv" runat = "server" Text = "*"  ErrorMessage = "Abbas" ForeColor = "Red"   ControlToValidate = "txt2" ValidationGroup = "a" Type"Integer" MinimumValue = "0" MaximumValue  = "10" /> 
        <br /> 
        <asp:Button ID = "btn" runat = "server" ValidationGroup = "a" OnClick = "btn_Click" Text=  "Press Me" CausesValidation = "true"/>  
        <asp:ValidationSummary ID = "sum" runat = "server" ValidationGroup = "a" ShowSummary = "true" DisplayMode = "BulletList" ShowMessageBox = "true" /> 
        </asp:Panel> 
        <rad:RadAjaxManager ID = "rad" runat = "server" > 
            <AjaxSettings> 
                <rad:AjaxSetting AjaxControlID = "pnl">  
                     <UpdatedControls> 
                        <rad:AjaxUpdatedControl ControlID = "pnl" /> 
                     </UpdatedControls> 
                </rad:AjaxSetting> 
            </AjaxSettings> 
        </rad:RadAjaxManager> 
          
          
    </div> 
    </form> 
</body> 
</html> 
 

 

 

 

The Code Behind is as Following

using System;  
using System.Collections.Generic;  
using System.Web;  
using System.Web.UI;  
using System.Web.UI.WebControls;  
 
namespace WebApplication1  
{  
    public partial class _Default : System.Web.UI.Page  
    {  
        protected void Page_Load(object sender, EventArgs e)  
        {  
 
        }  
 
        protected void txt1_TextChanged(object sender, EventArgs e)  
        {  
            int x = 0;  
            int.TryParse(txt1.Text, out x);  
            rv.MaximumValue = x.ToString ();  
            rad.Alert ("Maximum Value Set");  
        }  
 
        protected void btn_Click(object sender, EventArgs e)  
        {   
            rad.Alert ("Button Post Back");  
        }  
    }  
}  
 


You will notice that the RangeValidator by default has the MaximumValue "10", Lets take the following Scenario :-

  1. Open the Page in your IE
  2. Type in a value of 200 in the First Text Box
  3. You will get an Alert that the 200 has been set as the MaximumValue from the TextChanged Event of the TextBox
  4. Now try to put 220 in the Second TextBox , then click the Press Me button.
  5. Well, You will notice that the Validation Summary Displayed that the Value is out of range.
  6. Now it should be obvious that trying enter a value that is below the 200 would be IN the range.
  7. Now Put 180, 160, 100, Try all the values and click the Press Me button, you will always get the Validation as active!.
  8. Finally Try to put 9 (Which is actually below the MaximumValue that was hardcoded declaratevely in the ASPX) and press the Press Me button. !! Wow the Page will post back finally and you will get the Alert from the Button "Button Post Back"

Now after some investigation, there is some problem with this validator, At first i thought it was a problem with all the Expando Attributues in the Valiadators, But it turned out to be this RangeValidator that has this specific problem.

Kindly inform us what should we do ?

2 Answers, 1 is accepted

Sort by
0
Ahmed
Top achievements
Rank 1
answered on 15 Jun 2009, 04:01 PM
Is there is something wrong with this post ??, Where is the Telerik Team, Why didn't any body respond ?
0
Iana Tsolova
Telerik team
answered on 16 Jun 2009, 08:45 AM
Hello Ahmed,

Please note that according our Support Options the guaranteed response time for this thread is 72h. (Mon - Fri). I suggest that you open formal support tickets for your urgent cases.

I tested your code and it worked fine on my side. Can you check the attached sample?

Additionally, find more about RadAjax and MS Standard Validators here.

Sincerely yours,
Iana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Ajax
Asked by
Ahmed
Top achievements
Rank 1
Answers by
Ahmed
Top achievements
Rank 1
Iana Tsolova
Telerik team
Share this question
or