I have a panel and dropdown like so
In the code behind I attach a JS function to the onchange event of the dropdown. Here is the JS function
Basically, I pass in the client id of the drop down. It then reads the value and decides whether or not to show some text boxes. They are set to display none by default. The problem I have is, when I do a post back with the ajax panel, the text boxes go back to being hidden. I am also calling this javascript function in the page load. When I remove the ajax panel, it sees the dd and keeps the text boxes visible. However, when I add the ajaxpanel back in, the textboxes go back to hidden on the postback. Any ideas why?
<
telerik:RadAjaxPanel
runat
=
"server"
ID
=
"panel"
LoadingPanelID
=
"loadingPanel"
>
<
asp:DropDownList
ID
=
"itemDrop"
runat
=
"server"
></
asp:DropDownList
>
</
telerik:RadAjaxPanel
>
<
telerik:RadAjaxLoadingPanel
ID
=
"loadingPanel"
BackgroundPosition
=
"Center"
runat
=
"server"
>
<
img
id
=
"Img1"
alt
=
"Loading..."
src
=
"~/images/loading.gif"
runat
=
"server"
style
=
"border: 0px;"
/>
</
telerik:RadAjaxLoadingPanel
>
In the code behind I attach a JS function to the onchange event of the dropdown. Here is the JS function
function
showFields(id) {
var
dd = document.getElementById(id);
var
itemArr = (dd.options[dd.selectedIndex].value).split(
";;;"
);
var
perDiv = document.getElementById(
"percentDiv"
);
var
quantDiv = document.getElementById(
"quantityDiv"
);
var
disValue = itemArr[1];
var
item = itemArr[0];
if
(item ==
"-1"
) {
perDiv.style.display =
"none"
;
quantDiv.style.display =
"none"
;
}
else
{
//see if we show quantity as well
if
(disValue > 0) {
perDiv.style.display =
"block"
;
quantDiv.style.display =
"block"
;
}
else
{
perDiv.style.display =
"none"
;
quantDiv.style.display =
"block"
;
}
//if disValue > 0
}
//if item == -1
}
Basically, I pass in the client id of the drop down. It then reads the value and decides whether or not to show some text boxes. They are set to display none by default. The problem I have is, when I do a post back with the ajax panel, the text boxes go back to being hidden. I am also calling this javascript function in the page load. When I remove the ajax panel, it sees the dd and keeps the text boxes visible. However, when I add the ajaxpanel back in, the textboxes go back to hidden on the postback. Any ideas why?