Click here to Skip to main content
15,887,676 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
protected string GMap1_Click1(object s, GAjaxServerEventArgs e)
    {
       
        if (rdo_circle.Checked)
        {
         
            return "circle clicked";

        }
        else
        {
    
            return "polygon clicked";

        }

    }


XML
<body>
    <form runat="server">
    <asp:RadioButton ID="rdo_polygon" runat="server" Text="Draw Polygon" GroupName="r" Checked="true"/>
    <asp:RadioButton ID="rdo_circle" runat="server" Text="Draw Circle" GroupName="r" />
    <cc1:GMap ID="GMap1" runat="server" enableServerEvents="True" OnClick="GMap1_Click1" />
     </form>
</body>



i check radio button but all time both button give false value
if check radio circle button than it return false value and not true condition
if i change condition up-down than also run false condition

please help me how to run true condition...
Posted
Updated 16-Oct-13 22:44pm
v3
Comments
Dharmendra-18 17-Oct-13 4:52am    
use radio button property auto post back and clear other on it..
Bama Boy 17-Oct-13 4:54am    
i used but not run
it run only false condition
[no name] 17-Oct-13 5:56am    
r u checked ur group name?go to the radio button property then put same group name for both radio button.
Bama Boy 17-Oct-13 5:59am    
in above code i also declare group name "r" for both
hsakarp 18-Oct-13 2:44am    
I guess the problem is with cc1:GMap. Have you tried with direct button click event?

1 solution

Replace your two radio buttons with radiolist as below

XML
<asp:radioButtonList ID="rbtlistdrawings" runat="server" RepeatLayout="Flow" RepeatDirection="Horizontal">
</asp:radioButtonList>


and put this piece of code in page_load evevt

C#
if (!IsPostBack)
            {
                rbtlistdrawings.Items.Add("Draw Polygon");
                rbtlistdrawings.Items.Add("Craw Circle");
            }


lastly change the Gmap_click1 event as below

C#
protected string GMap1_Click1(object s, GAjaxServerEventArgs e)
    {

        if (rbtlistdrawings.SelectedIndex == 0)
        {

            return "polygon clicked";

        }
        else
        {

            return "Circle clicked";

        }

    }
 
Share this answer
 
Comments
Bama Boy 29-Oct-13 5:23am    
ohk sir i try
Bama Boy 29-Oct-13 5:44am    
not working sir...its return -1
HariPrasad katakam 29-Oct-13 6:15am    
Have you put below code inside your Page Load and inside if(!IsPostBack){} block?

if (!IsPostBack)
{
rbtlistdrawings.Items.Add("Draw Polygon");
rbtlistdrawings.Items.Add("Craw Circle");
}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900