By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,453 Members | 3,194 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,453 IT Pros & Developers. It's quick & easy.

checking one checkbox with other Checkbox present in different views of a multiview

P: 22
i am having a web based application and i am having a problem with it pls check it
Explanationi am sending a sample code plese see it in VS-2005 FOR BETTER UNFERSTANDING

I have a main page called DEFAULT.ASPX
it has a drop down list and 3 contentplace holders


dropdown list With 3 parameters A,B,C if i select any options in drop down list the respective Content place holder will add respective user control and get Visible.

for example A is selected in drop down ------- content place holder A is selected and it will add A.ascx file and get visible


IN the USer control file it has link buttons and a MULTIVIEW, the multiview in turn has some views and each view has checkboxes.



THE PROBLEM

here When i check checkbox A1 from view1 then checkbox A2 in view 2 should automatically checked. (client side and i have use javascript)



example

default.aspx script code

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

<%@ Register Src="~/A.ascx" TagName="ucFernandez" TagPrefix="uc1" %>
<%@ Register Src="~/C.ascx" TagName="wucAdmin" TagPrefix="uc3" %>
<%@ Register Src="~/B.ascx" TagName="wucClient" TagPrefix="uc2" %>

<!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 id="Head1" runat="server">
<title>Case Sheet</title>
</head>
<body topmargin=0 bottommargin=0 leftmargin=0 rightmargin=0>
<form id="form1" runat="server">
<div>
<table width="100%">
<tr>
<td colspan="5" align="center" style="height: 85px" >
<!--Hospital Table -->
<fieldset style="background-color: #e1f3ff">
<table border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="#e1f3ff">
<tr>
<td colspan="6">
</td>
</tr>
<tr>
<!--Select Hospital-->
<td valign="middle" width="16%" align="left">
<asp:Label ID="lblselectone" runat="server" Font-Size="11pt" Text='select one place holder' Width="188px"
Height="12px" ForeColor="Black" Font-Names="Verdana"></asp:Label>
</td>
<td align="Left" width="16%">
<asp:DropDownList ID="ddlSelectone" runat="server" Font-Size="10pt" Width="120px" AutoPostBack="True" >
<asp:ListItem>A</asp:ListItem>
<asp:ListItem>B</asp:ListItem>
<asp:ListItem>C</asp:ListItem>
</asp:DropDownList></td>
<!--Case.No(Total)-->
<td align="left" colspan="4">
&nbsp; &nbsp;&nbsp;</td>
<!--Case.No(Hospital)-->
</tr>
</table>
</fieldset>
<!-- End of Hospital Details-->
</td>
</tr>
<tr>
<td width=100% valign=top style="height: 16px">
<asp:PlaceHolder ID="PleacepholderA" runat="server" Visible="False"></asp:PlaceHolder>
<asp:PlaceHolder ID="PlaceHolderB" runat="server" Visible="False"></asp:PlaceHolder>
<asp:PlaceHolder ID="PlaceHolderC" runat="server" Visible="False"></asp:PlaceHolder>
</td>
</tr>
<tr>
</tr>
</table>


</div>
</form>
</body>
</html>


default.aspx.cs sample code

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)
{
if (Page.IsPostBack == false)
{

if (ddlSelectone.SelectedIndex == 0)
{
PlaceHolderB.Visible = false;
PlaceHolderC.Visible = false;
PleacepholderA.Controls.Clear();
Control fuc = (UserControl)Page.LoadControl("~/A.ascx");
PleacepholderA.Controls.Add(fuc);
PleacepholderA.Visible = true;

}
}
else
{
if (ddlSelectone.SelectedIndex == 0)
{
PlaceHolderB.Visible = false;
PlaceHolderC.Visible = false;
Control fuc = (UserControl)Page.LoadControl("~/A.ascx");
PleacepholderA.Controls.Add(fuc);
PleacepholderA.Visible = true;
}
else if (ddlSelectone.SelectedIndex == 1)
{
PleacepholderA.Visible = false;
PlaceHolderC.Visible = false;
Control guc = (UserControl)Page.LoadControl("~/B.ascx");
PlaceHolderB.Controls.Add(guc);
PlaceHolderB.Visible = true;
}
else if (ddlSelectone.SelectedIndex == 2)
{
PlaceHolderB.Visible = false;
PleacepholderA.Visible = false;
Control huc = (UserControl)Page.LoadControl("~/C.ascx");
PlaceHolderC.Controls.Add(huc);
PlaceHolderC.Visible = true;
}
else
{

}
}
}

}

A.ascx sample code


<%@ Control Language="C#" AutoEventWireup="true" CodeFile="A.ascx.cs" Inherits="_1" %>

<table width="100%">
<tr>
<td align="center" colspan="5">
<table width="100%">
<tr height="35">
<td align="center" class="ele_button" valign="middle" width="20%">
<asp:LinkButton ID="lbview1" runat="server" Font-Bold="True" Font-Names="Verdana"
Font-Size="10pt" Font-Underline="False" ForeColor="Black" Height="100%"
Text="view1" Width="100%" OnClick="lbview1_Click"></asp:LinkButton></td>
<td align="center" class="ele_button" valign="middle" width="20%">
<asp:LinkButton ID="lbview2" runat="server" Font-Bold="True" Font-Names="Verdana"
Font-Size="10pt" Font-Underline="False" ForeColor="Black" Height="100%"
Text="view2" Width="100%" OnClick="lbview2_Click"></asp:LinkButton></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<asp:MultiView ID="MultiViewA" runat="server">
<asp:View ID="View1" runat="server">
<asp:CheckBox ID="cbxA1" runat="server" Text="A1" /></asp:View>
<asp:View ID="View2" runat="server">
<asp:CheckBox ID="cbxA2" runat="server" Text="A2" /></asp:View>
</asp:MultiView></td>
</tr>
</table>




A.ascx.cs file

sing 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 _1 : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}

protected void lbview1_Click(object sender, EventArgs e)
{
MultiViewA.ActiveViewIndex = 0;
}
protected void lbview2_Click(object sender, EventArgs e)
{
MultiViewA.ActiveViewIndex = 1;
}
}


wht should i do please sugesst in this regard pls send me a sample code as it would be helpfull.

thanks and regard
vijay
Jun 8 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.