EXT.NET 3.0.0 RELEASED!
Now with Tablet Support!
Ext.NET 3.0.0 is here with lots of new cool features and now with tablet support! Check Examples Explorer now to see it in action or download and test it yourself for free!
Results 1 to 6 of 6

Thread: How to write a script for alerting select at least one radio button

  1. #1
    Member
    Join Date
    Mar 2012
    Posts
    19

    How to write a script for alerting select at least one radio button

    I have written a code where I will get the selected text of radio button in an alert, but what I need is if user clicks on select with out selecting any radio button I would like to show an alert form the script. This is my code

    Code:
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default5.aspx.cs" Inherits="Default5" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!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></title>
    </head>
    <body>
        <form id="form1" runat="server">
          <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <div>
            <ext:FormPanel ID="frm" runat="server">
                <Items>
                    <ext:RadioGroup ID="RadioGroup1" runat="server" FieldLabel="Votre Sex ">
                        <Items>
                            <ext:Radio ID="Radio1" runat="server" BoxLabel="Male" />
                            <ext:Radio ID="Radio2" runat="server" BoxLabel="Female" />
                        </Items>
                    </ext:RadioGroup>                
                    <ext:Button ID="Button1" runat="server" Text="Submit">
                        <DirectEvents>
                            <Click OnEvent="Button1_Click">
                            </Click>
                        </DirectEvents>
                    </ext:Button>
                </Items>
            </ext:FormPanel>
        </div>
        </form>
    </body>
    </html>
    
    My code behind code 
    
    protected void Button1_Click(object sender, DirectEventArgs e)
        {
            
            string chk = RadioGroup1.CheckedItems[0].BoxLabel.ToString();
            if (chk != null)
            {
                X.MessageBox.Alert("Click", chk).Show();
            }
            else
            {
                X.MessageBox.Alert("Click", "Select").Show();
            }
        }

  2. #2
    Ext.NET - Support Team Daniil's Avatar
    Join Date
    Jun 2010
    Location
    Saint-Petersburg, Russia
    Posts
    28,056
    Hi,

    Here you are.

    Example
    Code:
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Submit(object sender, DirectEventArgs e)
        {
            X.Msg.Alert("Submit", this.RadioGroup1.CheckedItems[0].BoxLabel).Show();
        }
    </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 v2 Example</title>
    
        <script type="text/javascript">
            var onBeforeSubmit = function (radioGroup) {
                if (Ext.isEmptyObj(radioGroup.getValue())) {
                    Ext.Msg.alert("Error", "Select an item.");
                    return false;
                }   
            };
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:RadioGroup ID="RadioGroup1" runat="server" ColumnsNumber="1">
                <Items>
                    <ext:Radio runat="server" BoxLabel="Radio 1" />
                    <ext:Radio runat="server" BoxLabel="Radio 2" />
                </Items>
            </ext:RadioGroup>
            <ext:Button runat="server" Text="Submit">
                <DirectEvents>
                    <Click OnEvent="Submit" Before="return onBeforeSubmit(#{RadioGroup1})" />
                </DirectEvents>
            </ext:Button>
        </form>
    </body>
    </html>
    Daniil
    Ext.NET, Inc.
    Support Team

    Ext.NET Examples | Ext.NET API Docs | ExtJS API Docs | Twitter | Jobs

  3. #3
    Member
    Join Date
    Mar 2012
    Posts
    19

    Adding ICONS

    Thanks mate how can I add Icons to this message boxes..
    Last edited by Dorababu; Mar 09, 2012 at 12:37 PM. Reason: Removed Quote

  4. #4
    Ext.NET - Support Team Daniil's Avatar
    Join Date
    Jun 2010
    Location
    Saint-Petersburg, Russia
    Posts
    28,056
    Please keep one issue per one thread.
    Daniil
    Ext.NET, Inc.
    Support Team

    Ext.NET Examples | Ext.NET API Docs | ExtJS API Docs | Twitter | Jobs

  5. #5
    Member
    Join Date
    Mar 2012
    Posts
    19
    Daniil ,

    Ok shall I post a new thread for this

  6. #6
    Ext.NET - Support Team Daniil's Avatar
    Join Date
    Jun 2010
    Location
    Saint-Petersburg, Russia
    Posts
    28,056
    Yes, please start a new forum thread.
    Daniil
    Ext.NET, Inc.
    Support Team

    Ext.NET Examples | Ext.NET API Docs | ExtJS API Docs | Twitter | Jobs

Similar Threads

  1. Radio Button
    By Vaishali in forum 1.x Help
    Replies: 4
    Last Post: Feb 07, 2012, 8:00 AM
  2. how to attatch value to radio button
    By harshad.jadhav in forum 1.x Help
    Replies: 1
    Last Post: Oct 28, 2010, 4:06 PM
  3. Radio button Handler
    By vs.mukesh in forum 1.x Help
    Replies: 0
    Last Post: Jul 01, 2010, 10:55 AM
  4. Radio Button Select
    By Dinesh.T in forum 1.x Help
    Replies: 0
    Last Post: May 19, 2009, 9:30 AM
  5. [CLOSED] Radio Button help
    By heysol in forum 1.x Help
    Replies: 3
    Last Post: Oct 17, 2008, 1:01 PM

Posting Permissions