469,651 Members | 1,647 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,651 developers. It's quick & easy.

Call Server Code Without Postback

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
Nov 18 '05 #1
1 1887
Hi Fred,

To avoid refreshing the whole page, you could probably use the WebService
behavior:

"WebService behavior receives method calls from the client-side script and
sends a request to the Web Service. The results are returned to the client
script, and processing continues. The Web page can then use the information
in whatever context is required, such as updating some portion of page
rendering using DHTML.

"A key feature of the WebService behavior is that it enables client-side
script to access a Web Service without requiring navigation to another URL.
Using the WebService behavior approach, the portions of the page that are
indicated by the user's inputs can be dynamically updated using DHTML,
providing a significant improvement in the browsing experience."

http://msdn.microsoft.com/library/de...e/overview.asp

Ken

"Fred W" <1.***@comcast.net> wrote in message
news:f8**************************@posting.google.c om...
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


Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Mike Moore | last post: by
6 posts views Thread by Karl Hungus | last post: by
6 posts views Thread by Olivier Matrot | last post: by
7 posts views Thread by kaburke | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.