Hi friends
Well i done some trails like a idiot but i am struck some where do refer attachment and help me out ..!!
HELP me to make my code perfect
TY
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted Mar 12, 2013, 1:23 PM
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm3.aspx.cs" Inherits="WebApplication17.WebForm3" %>
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
namespace WebApplication17
{
public partial class WebForm3 : System.Web.UI.Page
{
int rent = 0, acost = 0;
protected void Button1_Click(object sender, EventArgs e)
{
if (RadioButton1.Checked==true)
rent = Convert.ToInt32(RadioButton1.ToolTip);
else if (RadioButton2.Checked == true)
rent = Convert.ToInt32(RadioButton2.ToolTip);
if (CheckBox1.Checked == true)
acost = Convert.ToInt32(CheckBox1.ToolTip);
if (CheckBox2.Checked == true)
acost = Convert.ToInt32(CheckBox2.ToolTip);
int total = acost + rent;
Label1.Text = "registered " + "" + TextBox1.Text + ":rent/day
" + total;
clear();
}
void clear()
{
TextBox1.Text = "";
RadioButton1.Checked = false;
RadioButton2.Checked = false;
CheckBox1.Checked = false;
CheckBox2.Checked = false;
}
}
}
SUNIL GUTTAPosted Mar 13, 2013, 12:33 PM
Vishal Gilbile Here there is no need for auto post back to set TRUE for radio & checkboxes
Satyapriya Nayak here in ur answered post as well as my in my attachment there a minor error of judgement i.e here it goes [in ur code we don't require clear without this replace below code we get it ]
Under check-boxes condition the correct way is
if (CheckBox1.Checked == true)
acost = Convert.ToInt32(CheckBox1.ToolTip);
if (CheckBox2.Checked == true)
acost = acost + Convert.ToInt32(CheckBox2.ToolTip); & remove clear() & logic of it :)
If replace this in ur & my code we get the o/p :)
Sorry for the trouble & ty for replies :) TY
Vishal GilbilePosted Mar 13, 2013, 12:41 AM
what i've understood from your problem is that you need to set the AutoPostback property of the RadioButton and Checkboxes to true if you are not getting the proper selection.
Hope that solves your problem.
With Regards,
Vishal Gilbile.
SUNIL GUTTAPosted Mar 12, 2013, 2:17 PM