i want to values sending with checkbox in asp.net using C# to another page

Recommended Answers

All 5 Replies

Welcome santhoshvarma.a,
You may send/pass value from one page to another page using querystring, and session.

i want to values sending with checkbox in asp.net using C# to another page.i want code and how to set value in <asp:checkbox> tag.
plz make itr fast

thank u & regards

A,santhosh kumar

hi please use the following... take a checkbox .. and give the text property as ur wish... (here i have given hello)

default.aspx: source code

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!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>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="True" OnCheckedChanged="CheckBox1_CheckedChanged"
            Text="Hello" /></div>
    </form>
</body>
</html>

default.aspx.cs (codebehind ):

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }
    protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
    {
        if (CheckBox1.Checked == true)
        {
            Response.Redirect("default1.aspx?val=" + CheckBox1.Text);
        }

    }
}

Next page (default1.aspx):

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Default1 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Write("This is secondpage");
        Response.Write(" "+Request.QueryString[0].ToString());
    }
}

Pls let me know if u have any questions on this..

Mark it as solved if u found soln

Thank u for giving me solution. but iam working with gridview and checkbox when click the checkbox it must select query value and send a value with checkbox to next page.For Ex:select empno,empname,city from employees tables.In aspx page it display empno,empname and city if i checked the checkbox and click submit button then the values must go the next page .

thanks and regards
Santhosh kumar

3 threads merge together. Please do not flood forum with same question, simply reply to already existing thread with new updated informations!

commented: Thanks! +13
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.