Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;



public class class1
{
    public double r, e, d;
    public class1()
    {
        r = 0;
        e = 0;
        d = 0;
    }
    public void convertdtor()
    {
        r = d * 78;
    }
    public void convertrtod()
    {
        d = r / 78;
    }
    public void convertetor()
    {
        r = e * 80;
    }
    public void convertrtoe()
    {
        e = r / 80;
    }
}

namespace MoneyConversion
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        class1 f1;
    protected void Page_Load(object sender, EventArgs e)
    {
     f1 = new class1();
    }
    protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
      {
    if (RadioButton1.Checked == true)
        {
          f1.d = Convert.ToInt16(TextBox1.Text);
          f1.convertdtor();
          Response.Write(f1.d + "Dollar" + "=Rs" + f1.r);

         }
      }


What I have tried:

tried to group them with same, set autopostback property as true but its not working. My program is basically to create money convertor app for dollars to rupees as of now and 3 more using radiobuttons
Posted
Updated 8-Aug-23 5:13am

1 solution

"Does not exist in the current context" is a simple error message - it's saying that the field, property, method, or control does not exist in the class in which you are trying to reference it.

Assuming you didn't just mispell or change the control name, check that the HTML /XML code that defines it includes runat="server":
ASP.NET
<asp:RadioButton id="Radio1" Text="Typical" Checked="True" GroupName="RadioGroup1" runat="server" /><br />
and that the id field matches that used by your C# code.

You can also use the sender parameter of the handler method:
C#
protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
   {
   if (sender is RadioButton rb)
       {
       if (rb.Checked)
           ...
But that will depend on what you are actually intending to do with your buttons.
 
Share this answer
 

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