[CLOSED] Adding RemoteValidation ExtraParams in server side but when RemoteValidation fired, the ExtraParams are ignored

  1. #1

    [CLOSED] Adding RemoteValidation ExtraParams in server side but when RemoteValidation fired, the ExtraParams are ignored

    Hello:

    I have a user control which has a textField and textField is enable RemoteValidation. I add the ExtraParams to RemoteValidation on the server side, on "OnPreRender" but when the validation fired, I track the HTTP trace and found only "id" and "value" has send to server. The ExtraParams which I added on server side are totally missing.
    here is the example for how I add the ExtraParames in RemoteValidataion in server side.
    textFieldName.RemoteValidation.ExtraParams.Add(new Parameter("planID", "this.PlanId", ParameterMode.Raw));
    Could you tell me what's the problem it is? Thank you

    Tom
    Last edited by Daniil; Aug 01, 2011 at 5:05 PM. Reason: [CLOSED]
  2. #2
    Hi,

    ExtraParams should not be ignored.

    Pleas provide your test case to reproduce the problem.

    Here is my test case which works fine.

    Example

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void TextField_Validation(object sender, RemoteValidationEventArgs e)
        {
            X.Msg.Alert("Test", e.ExtraParams["test"]).Show();
            e.Success = true;
        }
    </script>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.Net Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:FormPanel runat="server">
                <Items>
                    <ext:TextField runat="server" FieldLabel="TextField" IsRemoteValidation="true">
                        <RemoteValidation OnValidation="TextField_Validation">
                            <ExtraParams>
                                <ext:Parameter Name="test" Value="test" Mode="Value" />
                            </ExtraParams>
                        </RemoteValidation>
                    </ext:TextField>
                </Items>
            </ext:FormPanel>
        </form>
    </body>
    </html>
  3. #3
    Hi Daniil:

    Thank you for the reply. My case is not add the ExtraParams in the page or view.
    Actually I create a user control which is inherit from Ext.Net.Panel. In the user control, I create a TextField which enabled RemoteValidation.
    In the RemoteValidation, I add a Ext.Net.Parametr in ExtraParams. But when the validation fired, the ExtraParams didn't send to server.
    Here is my simplify code.

    UserControlPanel.cs
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Ext.Net;
    using WBS.Workware.Resources;
    
    namespace WBS.Workware.Web.Controls
    {
        public class PlanDetails : Panel
        {
    
             public string Name
            {
                get
                {
                    return (string)ViewState["Name"];
                }
                set
                {
                    ViewState["Name"] = value;
                }
            }
    
            public int ContainerId
            {
                get
                {
                    return (int) ViewState["ContainerId"];
                }
                set
                {
                    ViewState["ContainerId"] = value;
                }
            }
    
            protected override void OnPreRender(EventArgs e)
            {
                base.OnPreRender(e);
                
                var textFieldName = new TextField()
                                        {
                                            ID = "textName",
                                            Width = 270,
                                            AllowBlank = false,
                                            MaxLength = 50,
                                            MinLength = 4,
                                            FieldLabel = "Name",
                                            ValidateOnBlur = false,
                                            MsgTarget = MessageTarget.Side,
                                            Text = Name,
                                            BlankText = "You must input the name.",
                                            IsRemoteValidation = true,
                                        };
                textFieldName.RemoteValidation.Url = "~/UserControll/CheckName";
                textFieldName.RemoteValidation.Json = true;
                textFieldName.RemoteValidation.Delay = 300;
                textFieldName.RemoteValidation.ExtraParams.Add(new Parameter("containerID", "this.containerId", ParameterMode.Raw));
                textFieldName.Listeners.BeforeRemoteValidation.Handler = "return this.originalIsValid(true);";
                textFieldName.SelectOnFocus = true;
                textFieldName.Focus();
                    this.LayoutConfig.Add(new VBoxLayoutConfig() { Align = VBoxAlign.Stretch, DefaultMargins = "10 25 10 10" });
                    this.Items.Add(textFieldName);
                    this.Items.Add(textAreaDescription);
                    this.Items.Add(textAreaComment);
                base.OnInit(e);
            }
    
            protected override void PreRenderAction()
            {
                this.CustomConfig.Add(new ConfigItem() { Name = "Name", Value = "'" + this.Name + "'", Mode = ParameterMode.Raw });
                this.CustomConfig.Add(new ConfigItem() { Name = "ContainerId", Value = "'" + this.ContainerId + "'", Mode = ParameterMode.Raw });
                base.PreRenderAction();
            }
        }
    }
  4. #4
    Please remove
    textFieldName.RemoteValidation.Json = true;
    Also, I think, this parameter
    new Parameter("containerID", "this.containerId", ParameterMode.Raw)
    will consists "undefined" value, because the TextField ('this' reference) have no "containerId" property.

    I can suggest you to make this parameter within the BeforeRemoteValidation listener:
    textFieldName.Listeners.BeforeRemoteValidation.Handler = @" options.params.containerID = this.ownerCt.containerId;
                                                                return this.originalIsValid(true);";
    A one note more that it looks strange:
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);
    
        ...
    
        base.OnInit(e);
    }
    And, I think, you can use OnInit event instead of OnPreRender.
  5. #5
    Quote Originally Posted by Daniil View Post
    Please remove
    textFieldName.RemoteValidation.Json = true;
    Also, I think, this parameter
    new Parameter("containerID", "this.containerId", ParameterMode.Raw)
    will consists "undefined" value, because the TextField ('this' reference) have no "containerId" property.

    I can suggest you to make this parameter within the BeforeRemoteValidation listener:
    textFieldName.Listeners.BeforeRemoteValidation.Handler = @" options.params.containerID = this.ownerCt.containerId;
                                                                return this.originalIsValid(true);";
    A one note more that it looks strange:
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);
    
        ...
    
        base.OnInit(e);
    }
    And, I think, you can use OnInit event instead of OnPreRender.
    HI Daniil:

    I modified the code as you suggested but I got the error message as follow
    This request has been blocked because sensitive information could be disclosed to third party web sites when this is used in a GET request. To allow GET requests, set JsonRequestBehavior to AllowGet.
  6. #6
    Use Method parameter oа RemoteValidation
    textFieldName.RemoteValidation.Method = HttpMethod.POST;
    or set attribute [HttpGet] on method CheckName in UserControllController
  7. #7
    Quote Originally Posted by nightik View Post
    Use Method parameter oа RemoteValidation
    textFieldName.RemoteValidation.Method = HttpMethod.POST;
    or set attribute [HttpGet] on method CheckName in UserControllController
    Thanks nightik

Similar Threads

  1. AfterEdit after RemoteValidation?
    By chearner in forum 1.x Help
    Replies: 0
    Last Post: Oct 19, 2011, 6:15 PM
  2. [1.1] RemoteValidation
    By Timothy in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jul 12, 2011, 7:44 AM
  3. RemoteValidation ?
    By nanlinfeixue in forum 1.x Help
    Replies: 0
    Last Post: Jun 20, 2011, 10:49 AM
  4. [CLOSED] RemoteValidation ExtraParams are ignored
    By daneel in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Mar 11, 2011, 3:40 PM
  5. [CLOSED] [1.0] RemoteValidation
    By Timothy in forum 1.x Legacy Premium Help
    Replies: 25
    Last Post: Dec 25, 2010, 1:07 PM

Posting Permissions