Not sure if anyone is using Obout and their Ajax features but if you are and you can help me, you are a life saver:
I have 2 panels that have drop downs in both.
I update the drop downs from the server and when I update 1 panel, I loss the values in the other panel. Can anyone explain what I am doing wrong?
I have included attachments and code.
HTML:
<script>
function ChangeGroup() {
ob_post.post(null, "onloadGroup", function(){});
}
function CurrentDate() {
var dStartDay = document.getElementById('d
dlStartDay
').value;
var dStartMonth = document.getElementById('d
dlStartMon
th').value
;
var dStartYear = document.getElementById('d
dlStartYea
r').value;
alert(dStartMonth + "/" + dStartDay + "/" + dStartYear);
ob_post.post(null, "onDate", function(){});
}
</script>
<oajax:CallbackPanel id="cpPanel1" runat="server">
<CONTENT>
<asp:dropdownlist id="ddlDropDown" runat="server" Width="168px" AutoPostBack="false"></asp
:dropdownl
ist>
</CONTENT>
<LOADING style="HEIGHT: 1px">
<TABLE height="100%" cellSpacing="0" cellPadding="0" width="100%">
<TR>
<TD vAlign="center" align="middle"></TD>
</TR>
</TABLE>
</LOADING>
</oajax:CallbackPanel>
<oajax:CallbackPanel id="cpPanel2" EnableViewState="true" RenderMethod="Always" Visible="true" ShowLoading="true" runat="server">
<CONTENT>
<SELECT id="ddlStartMonth" style="FONT-WEIGHT: bold; FONT-SIZE: xx-small; FONT-FAMILY: Verdana" runat="server" NAME="ddlStartMonth"></SEL
ECT>
<SELECT id="ddlStartDay" style="FONT-WEIGHT: bold; FONT-SIZE: xx-small; FONT-FAMILY: Verdana" runat="server" NAME="ddlStartDay"></SELEC
T>
<SELECT id="ddlStartYear" style="FONT-WEIGHT: bold; FONT-SIZE: xx-small; FONT-FAMILY: Verdana" runat="server" NAME="ddlStartYear"></SELE
CT>
</CONTENT>
<LOADING style="HEIGHT: 1px">
<TABLE height="100%" cellSpacing="0" cellPadding="0" width="100%">
<TR>
<TD vAlign="center" align="middle"></TD>
</TR>
</TABLE>
</LOADING>
</oajax:CallbackPanel>
<asp:button id="btnDate" runat="server" Font-Bold="True" Font-Size="XX-Small" Font-Names="Verdana" Text="What is the date" Width="120px" CausesValidation="False"><
/asp:butto
n><BR>
Vb Code behind:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim i As Integer
If Not Page.IsPostBack Then
'Pop day
For i = 1 To 31
ddlStartDay.Items.Add(i)
ddlStartDay.Items.FindByTe
xt(i).Valu
e = i
Next
ddlStartDay.Value = System.DateTime.Today.Day
'Pop month
For i = 1 To 12
ddlStartMonth.Items.Add(i & "-" & MonthName(i, False))
ddlStartMonth.Items.FindBy
Text(i & "-" & MonthName(i, False)).Value = i
Next
ddlStartMonth.Value = System.DateTime.Today.Mont
h
'PopYear
For i = -2 To 2
ddlStartYear.Items.Add(Sys
tem.DateTi
me.Today.Y
ear + i)
ddlStartYear.Items.FindByT
ext(System
.DateTime.
Today.Year
+ i).Value = System.DateTime.Today.Year
+ i
Next
ddlStartYear.Value = System.DateTime.Today.Year
ddlDropDown.Items.Add("Sel
ection 1")
ddlDropDown.Items.Add("Sel
ection 2")
End If
ddlDropDown.Attributes.Add
("onchange
", "ChangeGroup();return false;")
btnDate.Attributes.Add("on
click", "CurrentDate();return false;")
End Sub
Public Sub onloadGroup()
ShowAlert(ddlDropDown.Sele
ctedItem.V
alue)
ddlDropDown.Items.Clear()
ddlDropDown.Items.Add("Sel
ection 3")
ddlDropDown.Items.Add("Sel
ection 4")
UpdatePanel("cpPanel1")
End Sub
Public Sub onDate()
ShowAlert(ddlStartMonth.Va
lue & "/" & ddlStartDay.Value & "/" & ddlStartYear.Value)
UpdatePanel("cpPanel2")
End Sub