473,386 Members | 1,804 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 1992
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mike Moore | last post by:
Can an asp.net button that is a server side control call a client side java function when the button is clicked? If so, please provide example.....thanks.,
2
by: moondaddy | last post by:
I'm using vb.net and have an aspx page where I want to call a function in the code behind to do something on the backend and I want to call this function from a jscript function in the aspx page. ...
6
by: Karl Hungus | last post by:
Im using an xsl transformation so its not practical to use controls in the usual way, but I would still like to call methods in my codebehind class. usually Id just use onclick="<eventHandler>"...
3
by: lanem | last post by:
I want to call a server-side function, like a button's click event, from a client-side JavaScript function. How do I do that? Thanks.
6
by: Olivier Matrot | last post by:
Hello, This has probably been asked several times, but It must be clarified for me. I would like to know why sometimes during a postback Page_Load is called after the function marked for...
7
by: kaburke | last post by:
Is there a way to make a page at the receiving end of a Server.Transfer think that the request is a Postback? (When I say "think it is a Postback," I mean I want the page to go through the ENTIRE...
7
by: Tony Girgenti | last post by:
Hello. I'm trying to undetrstand ASP.NET 2.0 and javascript. When i have a button and i click on it and i see the web broswer progress bar at the bottom do something, does that mean that there...
4
by: TS | last post by:
Steven, i lost this message conversation from outlook express and made a post online (see last one on this page). Please answer it as it hasn't been yet. thanks The clientID of our controls...
5
by: Simon | last post by:
I heard that we could do that by using AJAX. Could anybody share how to do it? Thanks.
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.