473,386 Members | 1,698 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.

script question

HI all.
I am using .NET1.1 , C#.
For the most part I am using server side C# code for many pages and
have been coming along OK. But now, I would like to populate a listbox
on the client side (if possible) based on the user selection of an
item in a dropDownList .

I found this example and tryed it but the value added to the listBox
does not display. However, if I then postback for any other reason at
all (including click a button with no function attached to it) then
the new value added to the list appears.

aspx page <head> section:
<script language="C#" runat="server">
void oIndexChanged (Object sender, EventArgs e)
{
lbPrivileges.Items.Add("New_Item");
}
</script>

<asp:dropdownlist id="ddlDbObjects" style="Z-INDEX: blah blah blah
runat="server" OnSelectedIndexChanged="oIndexChanged">

autopostback for dropDownList is set to false.

1) Does this script run on the client side but result does not appear
or doesn't it even run?

2) This example code showed using C# language scipt. Would java script
be better and of so, what are the reasons for using one over the other
- C# code or java script - on client side.

3) What do I need to do accomplish my goal? Fix the above or something
entirely different?

Thanks
Jeff
Feb 12 '06 #1
2 1409
There is no client script there. It all runs on the server, which would
explain why it only appears after a postback.

Just because code is in the HTML page, does not mean it runs on the client.
Also, whenever you have a runat=server, the attached events are processed on
the server, not client. Also, IE cannot run C# code.

Now, you can use JavaScript, but then during a postback, your values would
disappear because the server would not be able to map that new value you
added to some HTML on the page. For things like this, it is usually best to
do a postback and use something like SmartNavigation to prevent noticeable
refreshes of the page.

"Jeff User" <je*******@hotmail.com> wrote in message
news:80********************************@4ax.com...
HI all.
I am using .NET1.1 , C#.
For the most part I am using server side C# code for many pages and
have been coming along OK. But now, I would like to populate a listbox
on the client side (if possible) based on the user selection of an
item in a dropDownList .

I found this example and tryed it but the value added to the listBox
does not display. However, if I then postback for any other reason at
all (including click a button with no function attached to it) then
the new value added to the list appears.

aspx page <head> section:
<script language="C#" runat="server">
void oIndexChanged (Object sender, EventArgs e)
{
lbPrivileges.Items.Add("New_Item");
}
</script>

<asp:dropdownlist id="ddlDbObjects" style="Z-INDEX: blah blah blah
runat="server" OnSelectedIndexChanged="oIndexChanged">

autopostback for dropDownList is set to false.

1) Does this script run on the client side but result does not appear
or doesn't it even run?

2) This example code showed using C# language scipt. Would java script
be better and of so, what are the reasons for using one over the other
- C# code or java script - on client side.

3) What do I need to do accomplish my goal? Fix the above or something
entirely different?

Thanks
Jeff

Feb 12 '06 #2
Peter
Got it. Thanks!
That clears up a lot of questions for me.
Is there any good information in particlular that you might recommend
for me to get started with SmartNavigation?

Thanks again
Jeff
On Sat, 11 Feb 2006 17:27:04 -0800, "Peter Rilling"
<pe***@nospam.rilling.net> wrote:
There is no client script there. It all runs on the server, which would
explain why it only appears after a postback.

Just because code is in the HTML page, does not mean it runs on the client.
Also, whenever you have a runat=server, the attached events are processed on
the server, not client. Also, IE cannot run C# code.

Now, you can use JavaScript, but then during a postback, your values would
disappear because the server would not be able to map that new value you
added to some HTML on the page. For things like this, it is usually best to
do a postback and use something like SmartNavigation to prevent noticeable
refreshes of the page.

"Jeff User" <je*******@hotmail.com> wrote in message
news:80********************************@4ax.com.. .
HI all.
I am using .NET1.1 , C#.
For the most part I am using server side C# code for many pages and
have been coming along OK. But now, I would like to populate a listbox
on the client side (if possible) based on the user selection of an
item in a dropDownList .

I found this example and tryed it but the value added to the listBox
does not display. However, if I then postback for any other reason at
all (including click a button with no function attached to it) then
the new value added to the list appears.

aspx page <head> section:
<script language="C#" runat="server">
void oIndexChanged (Object sender, EventArgs e)
{
lbPrivileges.Items.Add("New_Item");
}
</script>

<asp:dropdownlist id="ddlDbObjects" style="Z-INDEX: blah blah blah
runat="server" OnSelectedIndexChanged="oIndexChanged">

autopostback for dropDownList is set to false.

1) Does this script run on the client side but result does not appear
or doesn't it even run?

2) This example code showed using C# language scipt. Would java script
be better and of so, what are the reasons for using one over the other
- C# code or java script - on client side.

3) What do I need to do accomplish my goal? Fix the above or something
entirely different?

Thanks
Jeff


Feb 12 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: el_roachmeister | last post by:
I have a 4000 line php cgi script that is not memory or cpu intensive. It runs in 1 second. Now I am getting a lot of customer requests to add in new features. My question is if there is a point...
0
by: Mark Griffin | last post by:
Hi... I am trying to convert a simple FAQ script to access mysql db rather than the Access db it was designed for. The originators of the script offer no support at all. I have managed to set...
2
by: Kingo | last post by:
Hi, First, please forgive my terrible knowledge of JS! I haven't used it in years. I am trying to create a Help page where a new question is on each line, and when clicking on the question,...
19
by: thisis | last post by:
Hi All, i have this.asp page: <script type="text/vbscript"> Function myFunc(val1ok, val2ok) ' do something ok myFunc = " return something ok" End Function </script>
4
dreamcatcher
by: dreamcatcher | last post by:
Hi everyone, I'm a frontend designer starting to learn about getting forms to work. What I'm after is a script that I can learn from and get working on a site relatively quickly. Something that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...

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.