F
Fred W
I have 2 dependent dropdowns and would like to populate the contents
of the child dropdown dynamically based on the selected item of the
parent.
Pretty standard requirement.
However, can this be done without posting back to the server each time
and without sending all possible data to the client first?
I'm attempting to call a server function, passing a value from the
client.
Here's some pseudocode that describes what I'm attempting:
<HTML>
</HEAD>
<script lang="jscript">
function SetDependentHtmlText(src){
var target = document.getElementById['divTarget'];
//the line below is the key piece of functionality
var newText = <%GetHtmlString(%> src.selecteditem.text <%)%>
target.innerHtml = serverText;
}
</script>
</HEAD>
<body>
<SELECT onchange='GetHtmlFromServer(this)'>
<OPTION>Color</OPTION>
<OPTION>Size</OPTION>
</SELECT>
<DIV id='divTarget'></DIV>
</HTML>
(C#)
string GetHtmlString(string keyValue)
{
if (keyValue = "Color")
return
"<SELECT>" +
"<OPTION>Red</OPTION>" +
"<OPTION>Blue</OPTION>" +
"</SELECT>"
}
- Fred
of the child dropdown dynamically based on the selected item of the
parent.
Pretty standard requirement.
However, can this be done without posting back to the server each time
and without sending all possible data to the client first?
I'm attempting to call a server function, passing a value from the
client.
Here's some pseudocode that describes what I'm attempting:
<HTML>
</HEAD>
<script lang="jscript">
function SetDependentHtmlText(src){
var target = document.getElementById['divTarget'];
//the line below is the key piece of functionality
var newText = <%GetHtmlString(%> src.selecteditem.text <%)%>
target.innerHtml = serverText;
}
</script>
</HEAD>
<body>
<SELECT onchange='GetHtmlFromServer(this)'>
<OPTION>Color</OPTION>
<OPTION>Size</OPTION>
</SELECT>
<DIV id='divTarget'></DIV>
</HTML>
(C#)
string GetHtmlString(string keyValue)
{
if (keyValue = "Color")
return
"<SELECT>" +
"<OPTION>Red</OPTION>" +
"<OPTION>Blue</OPTION>" +
"</SELECT>"
}
- Fred