473,837 Members | 1,689 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 SetDependentHtm lText(src){
var target = document.getEle mentById['divTarget'];
//the line below is the key piece of functionality
var newText = <%GetHtmlString (%> src.selectedite m.text <%)%>
target.innerHtm l = serverText;
}
</script>
</HEAD>
<body>
<SELECT onchange='GetHt mlFromServer(th is)'>
<OPTION>Color </OPTION>
<OPTION>Size</OPTION>
</SELECT>
<DIV id='divTarget'> </DIV>
</HTML>

(C#)
string GetHtmlString(s tring keyValue)
{
if (keyValue = "Color")
return
"<SELECT>" +
"<OPTION>Re d</OPTION>" +
"<OPTION>Bl ue</OPTION>" +
"</SELECT>"
}

- Fred
Nov 18 '05 #1
1 2008
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.goo gle.com...
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 SetDependentHtm lText(src){
var target = document.getEle mentById['divTarget'];
//the line below is the key piece of functionality
var newText = <%GetHtmlString (%> src.selectedite m.text <%)%>
target.innerHtm l = serverText;
}
</script>
</HEAD>
<body>
<SELECT onchange='GetHt mlFromServer(th is)'>
<OPTION>Color </OPTION>
<OPTION>Size</OPTION>
</SELECT>
<DIV id='divTarget'> </DIV>
</HTML>

(C#)
string GetHtmlString(s tring keyValue)
{
if (keyValue = "Color")
return
"<SELECT>" +
"<OPTION>Re d</OPTION>" +
"<OPTION>Bl ue</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
1444
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
3056
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. Furthermore I know there will be a postback involved but the state of the page will not change at all so I would like it to be as efficient as possible with no appearance to the user that anything happened. I saw in someone else's code where...
6
1405
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>" say for something like a button control is there a way to manually call a method defined in a codebehind class, but is not called by a standard control? I looked at the __doPostBack() function that .net generates but it seemed impenetrable.
3
15506
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
2401
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 postback. Here's the deal : From now on, I set CurrentThread.CurrentCulture only during PageLoad. so date and currency format is incorrect if page load is not called first. What should I do to ensure that CurrentThread.CurrentCulture is alway set...
7
3325
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 event sequence for a postback, including LoadViewState, ProcessPostData, etc.) Even when Sever.Transfer transfers a page to itself (i.e., Page A.aspx contains Server.Transfer("A.apsx")) the request is seen as a first-time request, not a Postback....
7
3367
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 is postback occurring? Does that mean a round trip to the server occurred? I keep reading javascript articles and tutorials that say "improve the client-side experience to be more responsive and quicker", but the articles
4
2703
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 have become very long since we have 2 master pages that our pages inherit from. Some team members at
5
2166
by: Simon | last post by:
I heard that we could do that by using AJAX. Could anybody share how to do it? Thanks.
0
9851
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10901
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10583
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10639
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9419
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7824
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5680
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5863
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3128
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.