[CLOSED] How to read dynamic checkbox value using request.form

  1. #1

    [CLOSED] How to read dynamic checkbox value using request.form

    Hi Guys,

    Is possible read dynamic checkbox value using Request.Form?

    This is my checkbox:

     var CheckItemAlternativa = new Ext.Net.Checkbox() { ID = "CK_" + objPer.IdPergunta + "_" + objAlternativa.IdAlternativa,
      Name = "CK_" + objPer.IdPergunta + "_" + objAlternativa.IdAlternativa, 
      FieldLabel = objAlternativa.Label, 
      Value = "s"};
       FieldSetQuestao.Items.Add(CheckItemAlternativa);

    This is my code to read all the values from form:
    It works with textField, I don't know how to do with checkboxes.


                foreach (var control in Request.Form.Keys)
                {
                    Classes.Resposta objResposta = new Classes.Resposta();
                    //get checkboxes values
                    if (control.ToString().StartsWith("CK_"))
                    {
                        if (!string.IsNullOrEmpty(Request.Form[control.ToString()]))
                        {
                             objResposta.Valor = Request.Form[control.ToString()];
    
                            listREsposta.Add(objResposta);
                        }
                    }
    Thank's in advance.
    Last edited by Daniil; Nov 11, 2014 at 4:27 AM. Reason: [CLOSED]
  2. #2
    Hi @debarry,

    Hope this helps.

    Example
    <%@ Page Language="C#" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                this.Form.Controls.Add(new Checkbox { ID = "Checkbox1", InputValue = "Some InputValue" });
            }
        }
    
        protected void Get(object sender, DirectEventArgs e)
        {
            string s = this.Request["Checkbox1"];
            bool check = false;
            string inputValue;
    
            if (s != null)
            {
                check = true;
                inputValue = s;
            }
            else
            {
                inputValue = "It cannot be read from the Request, because there is no such the information in the Request";
            }
    
            X.Msg.Alert("GetByRequest", "Checked: " + check + "<br/>InputValue: " + inputValue).Show();
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
    
            <ext:Button runat="server" Text="Get" OnDirectClick="Get" />
        </form>
    </body>
    </html>
  3. #3
    You may close the thread.

    Thank you.

Similar Threads

  1. [CLOSED] Get value RadioGroup Request Form
    By romeu in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 25, 2012, 11:20 AM
  2. Form doesn't read data unless activated
    By paul-2011 in forum 1.x Help
    Replies: 2
    Last Post: Jun 30, 2011, 7:43 PM
  3. Replies: 5
    Last Post: Sep 02, 2010, 9:49 AM
  4. [CLOSED] Can't read value from disabled checkbox
    By Pablo in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jul 02, 2009, 2:05 PM
  5. Replies: 0
    Last Post: Jun 08, 2009, 12:04 PM

Posting Permissions