Hi Guys
I got the selected values of reason of visit combobox (jawclickcboReason), when I click on save button of first user control.
After saving, second user control is loaded runtime.
In this control when I click on save button, I am not getting selected value of reason of visit (CboJawLockingcboReason).
Code is as below.
BaseUserControl.cs file code
**************************
using System.Collections.Generic;
using System.Web.UI;
namespace Ext.UC
{
/// <summary>
/// Summary description for BaseUserControl
/// </summary>
public class BaseUserControl : UserControl
{
public virtual List<string> ControlsToDestroy
{
get
{
// we should return none lazy controls only because lazy controls will be autodestroyed by parent container
return new List<string>();
}
}
}
}
********************************
Code in main aspx file
*********************************
<%@ Page Title="" Language="C#" AutoEventWireup="true" CodeFile="forumpage.aspx.cs" Inherits="Demo" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!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">
<script type="text/javascript">
var destroyFromCache = function(container) {
container.controlsCache = container.controlsCache || [];
Ext.each(container.controlsCache, function(controlId) {
var control = Ext.getCmp(controlId);
if (control && control.destroy) {
control.destroy();
}
});
};
var putToCache = function(container, controls) {
container.controlsCache = controls;
};
</script>
</head>
<body>
<form id="Form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:Viewport ID="Viewport1" runat="server" StyleSpec="background-color: transparent;">
<Items>
<ext:BorderLayout ID="BorderLayout1" runat="server">
<Center MarginsSummary="5 7 5 5">
<ext:TabPanel
ID="TabPanel1"
runat="server"
Title="TabPanel"
ActiveTabIndex="0"
TabAlign="Left"
TabPosition="Top"
Border="false"
BodyStyle="border:1px solid #AABBCC; border-top: none;">
<Items>
<ext:Panel
ID="TabComplaints"
runat="server"
Title="Complaints"
Icon="GroupError"
BodyStyle="background-color:#DDEEFF;"
Layout="Fit"
ButtonAlign="Center"
>
<Items>
<ext:GroupTabPanel ID="GroupTabPanel1" runat="server" TabWidth="180" Cls="vertical-tabs" BodyStyle="border:1px solid #82ACCE;" >
<Groups>
<ext:GroupTab ID="grpJawClicking" runat="server" Cls="topbottompadding">
<Items>
<ext:Panel ID="Panel5"
runat="server"
Title="JAW CLICKING"
TabTip="JAW CLICKING"
StyleSpec="padding:5px;" >
</ext:Panel>
</Items>
<DirectEvents>
<Show OnEvent="TempFunction"></Show>
</DirectEvents>
</ext:GroupTab>
</Groups>
</ext:GroupTabPanel>
<ext:GroupTab ID="grpJawLocking" runat="server" Cls="topbottompadding">
<Items>
<ext:Panel ID="Panel8"
runat="server"
Title="JAW LOCKING"
TabTip="JAW LOCKING"
StyleSpec="padding:5px;">
</ext:Panel>
</Items>
<DirectEvents>
<Show OnEvent="TempFunction"></Show>
</DirectEvents>
</ext:GroupTab>
</Items>
</ext:Panel>
</Items>
</ext:TabPanel>
</Center>
</ext:BorderLayout>
</Items>
</ext:Viewport>
</form>
</body>
</html>
**************************************
code in main aspx.cs file
******************************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Ext.Net;
using Ext.UC;
namespace AdsLogyTesting
{
public partial class forumpage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (GroupTabPanel1.ActiveGroupIndex == 0)
{
DisplayJawClicking();
}
else
{
DisplayJawLocking();
}
}
protected void DisplayJawLocking()
{
X.Js.Call("destroyFromCache", new JRawValue(Panel8.ClientID));
BaseUserControl uc2 = (BaseUserControl)this.LoadControl("UserControl/JawLockingControl.ascx");
uc2.ID = "UC3";
this.Panel8.ContentControls.Add(uc2);
X.Js.Call("putToCache", new JRawValue(Panel8.ClientID), uc2.ControlsToDestroy);
this.Panel8.UpdateContent();
//this.Button1.Disabled = false;
//this.Button2.Disabled = true;
}
protected void DisplayJawClicking()
{
X.Js.Call("destroyFromCache", new JRawValue(Panel5.ClientID));
BaseUserControl uc2 = (BaseUserControl)this.LoadControl("UserControl/JawClicking.ascx");
uc2.ID = "UC2";
this.Panel5.ContentControls.Add(uc2);
X.Js.Call("putToCache", new JRawValue(Panel5.ClientID), uc2.ControlsToDestroy);
this.Panel5.UpdateContent();
}
protected void TempFunction(object sender, EventArgs e)
{
}
}
}
************************************
COde in first user control ascx file
**********************************
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="JawClicking.ascx.cs" Inherits="UserControl_JawClicking" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<ext:Panel ID="jawclickPanel1" runat="server" Title="Jaw Clicking" Padding="5" BodyBorder="true"
Width="1040" Height="470" ButtonAlign="Center">
<Items>
<ext:Panel ID="jawclickPanel7" runat="server" Frame="true" Width="1000" BodyStyle="background-color:transparent;"
ButtonAlign="Center">
<Items>
<ext:Container ID="jawclickContainer1" runat="server" Layout="Column" Height="40"
BodyStyle="background-color:#fff;">
<Items>
<ext:Container ID="jawclickContainer2" runat="server" LabelAlign="Top" Layout="Form"
ColumnWidth=".33">
<Items>
<ext:ComboBox ID="jawclickcboReason" ForceSelection="false" runat="server" FieldLabel="Reason of Visit"
LabelStyle="color:#284382;font-weight:bold;" AnchorHorizontal="98%" AllowBlank="false">
<Items>
<ext:ListItem Text="New Symptoms" Value="New Symptons" />
<ext:ListItem Text="Exacerbation" Value="Exacerbation" />
<ext:ListItem Text="Recurrence" Value="Recurrence" />
</Items>
</ext:ComboBox>
</Items>
</ext:Container>
<ext:Container ID="jawclickContainer3" runat="server" LabelAlign="Top" Layout="Form"
ColumnWidth=".33">
<Items>
<ext:ComboBox ID="jawclickcboClicking" ForceSelection="false" runat="server" FieldLabel="Reason of clicking"
LabelStyle="color:#284382;font-weight:bold;" AnchorHorizontal="98%">
<Items>
<ext:ListItem Text="Accident" Value="Accident" />
<ext:ListItem Text="Trauma" Value="Trauma" />
</Items>
</ext:ComboBox>
</Items>
</ext:Container>
<ext:Container ID="jawclickContainer4" runat="server" LabelAlign="Top" Layout="Form"
ColumnWidth=".33">
<Items>
<ext:ComboBox ID="jawclickcboSymptoms" ForceSelection="false" runat="server" FieldLabel="When Symtomps Started?"
LabelStyle="color:#284382;font-weight:bold;" AnchorHorizontal="95%">
<Items>
<ext:ListItem Text="1-2 Weeks" Value="1-2 Weeks" />
<ext:ListItem Text="2-4 Weeks" Value="2-4 Weeks" />
<ext:ListItem Text="4-8 Weeks" Value="4-8 Weeks" />
</Items>
</ext:ComboBox>
</Items>
</ext:Container>
</Items>
</ext:Container>
</Items>
</ext:Panel>
</Items>
</ext:Panel>
<ext:Panel ID="pnlJawClickButton" runat="server" BodyBorder="false" Height="30" Width="1020"
ButtonAlign="Center">
<Buttons>
<ext:Button ID="btnsave" runat="server" Text="Save">
<Listeners>
<Click Handler="#{DirectMethods}.JawClickSave();" />
</Listeners>
</ext:Button>
</Buttons>
</ext:Panel>
*************************************
Code in First User control ascx.cs file
************************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Ext.Net;
using Ext.UC;
using System.Data;
public partial class UserControl_JawClicking : BaseUserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
public override List<string> ControlsToDestroy
{
get
{
// we should return none lazy controls only because lazy controls will be autodestroyed by parent container
return new List<string>
{
};
}
}
[DirectMethod]
public void DirectMethod()
{
}
[DirectMethod]
public void jawClickSave()
{
X.Msg.Alert("Message", jawclickcboReason.SelectedItem.Text).Show();
GroupTab gtp = new GroupTab();
gtp = ((GroupTab)this.Parent.FindControl("GroupTabPanel1").FindControl("grpJawLocking"));
gtp.SetActiveTab(0);
}
}
****************************************
Code in second user cotrol ascx file
************************************
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="JawLockingControl.ascx.cs"
Inherits="UserControl_JawLockingControl" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<ext:Panel ID="PnlJawLockingOuter" runat="server" Title="Jaw Locking" ButtonAlign="Center"
Padding="5" BodyStyle="background-color:transparent;" BodyBorder="true" Width="1040"
Height="450">
<Items>
<ext:Panel ID="PnlJawLockingInner" runat="server" Frame="true" Width="1000" BodyStyle="background-color:transparent;"
ButtonAlign="Center" >
<Items>
<ext:Container ID="CntJawLockingVisitReasonMain" runat="server" Layout="Column" Height="40"
BodyStyle="background-color:#fff;" >
<Items>
<ext:Container ID="CntJawLockingVisitReasonSub" runat="server" LabelAlign="Top" Layout="Form"
ColumnWidth=".33">
<Items>
<ext:ComboBox ID="CboJawLockingcboReason" runat="server" FieldLabel="Reason of Visit"
LabelStyle="color:#284382;font-weight:bold;" AnchorHorizontal="98%" SelectedIndex="0"
ForceSelection="false" Width="350">
<Items>
<ext:ListItem Text="Select" Value="Select" />
<ext:ListItem Text="New Symptoms" Value="New Symptons" />
<ext:ListItem Text="Exacerbation" Value="Exacerbation" />
<ext:ListItem Text="Recurrence" Value="Recurrence" />
<ext:ListItem Text="Other" Value="Other" />
</Items>
</ext:ComboBox>
</Items>
</ext:Container>
<ext:Container ID="CntJawLockingSymptoms" runat="server" LabelAlign="Top" Layout="Form"
ColumnWidth=".33">
<Items>
<ext:ComboBox ID="cboJawLockingSymptoms" runat="server" FieldLabel="When Symtomps Started?"
LabelStyle="color:#284382;font-weight:bold;" AnchorHorizontal="95%" SelectedIndex="0"
Width="350">
<Items>
<ext:ListItem Text="Select" Value="Select" />
<ext:ListItem Text="1-2 Weeks" Value="1-2 Weeks" />
<ext:ListItem Text="2-4 Weeks" Value="2-4 Weeks" />
<ext:ListItem Text="4-8 Weeks" Value="4-8 Weeks" />
<ext:ListItem Text="Other" Value="Other" />
</Items>
</ext:ComboBox>
</Items>
</ext:Container>
<ext:Container ID="CntJawLockingBlank" runat="server" LabelAlign="Top" Layout="Form"
ColumnWidth=".33">
<Items>
</Items>
</ext:Container>
</Items>
</ext:Container>
</Items>
</ext:Panel>
</Items>
</ext:Panel>
<ext:Panel ID="pnlJawLockingButton" ButtonAlign="Center" runat="server" BodyBorder="false" Height="30"
Width="1020">
<Buttons>
<ext:ImageButton ID="JawLockingSave" ImageUrl="../images/save.png" runat="server">
<Listeners>
<Click Handler="#{DirectMethods}.jawLockingSave();" />
</Listeners>
</ext:ImageButton>
</Buttons>
</ext:Panel>
*******************************
code in second user control ascx.cs file
********************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Ext.Net;
using Ext.UC;
public partial class UserControl_JawLockingControl : BaseUserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
public override List<string> ControlsToDestroy
{
get
{
// we should return none lazy controls only because lazy controls will be autodestroyed by parent container
return new List<string>
{
};
}
}
[DirectMethod]
public void DirectMethod()
{
}
[DirectMethod]
public void jawLockingSave()
{
X.Msg.Alert("Message", CboJawLockingcboReason.SelectedItem.Text).Show();
GroupTab gtp = new GroupTab();
gtp = ((GroupTab)this.Parent.FindControl("GroupTabPanel1").FindControl("grpJawClicking"));
gtp.SetActiveTab(0);
}
}
******************************************
Thanks in advance
Rupesh