Execute the client side and server side code



I have two drop down lists one ddl1, ddl2.

when ddl1 index is changed I have to change the label before the ddl1 and contents of ddl2.

1) to change the label before ddl2, I am using the javascript like this:

ddl1.Attributes.Add("onchange", "changeLabelText(this); return false;");

Javascript function

<script language="javascript">

function changeLabelText(ddl) {

var indx = ddl.selectedIndex;

var lbl = document.getElementById('<%= lblSelect.ClientID %>');

if(indx == 0)

lbl.innerHTML = "Select A:";

if(indx == 1)lbl.innerHTML = "Select B:";



2) To change the contents I need to use ddl1_SelectedIndexChanged event:

In that event I included the code to populate the ddl2 contents.

When I include the javascript code to change the label that Slected_indexchanged event is not firing. without this code it is working fine.

Thanks in advance
12/19/2007 10:28:41 PM
asp.net.getting-started 91979 articles. 4 followers. Follow

6 Replies

Similar Articles

[PageSpeed] 47
Get it on Google Play
Get it on Apple App Store

Remove the return false from the javascript code which will stop the postback

 ddl1.Attributes.Add("onchange", "changeLabelText(this);");


Haissam Abdul Malak
| Blog |
12/20/2007 12:11:16 AM



If I remove return false, Then the javascript function code is not working. drop down list event is firing.

Thanks in advance

12/20/2007 1:30:32 AM

 Hi there:

Is that you want to change the datesource of the second one if the first one selected item change? if so,why don't you use ajax, it is simple

12/20/2007 1:35:55 AM


 In our project, our people don't want to use AJAx.



12/20/2007 3:07:48 PM

Try return true; instead of return false;

Let Me Google That For You!
12/20/2007 3:19:28 PM

Hi Kal,

Based on my understanding, you want to change the Label’s value using JavaScript and bind another control in the server side event when the user changes the DropDownList’s item.  If I have misunderstood you, please feel free to let me know.

If the DropDownList’s SelectedIndexChanged event is fired, the Label’s value we change using JavaScript will be lost because of the page postback.

We can also change the Label’s value in this SelectedIndexChanged event. If we do so, we don’t need to write the JavaScript.

I hope this helps. 

Thomas Sun
Microsoft Online Community Support

Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question.
12/21/2007 4:10:17 AM

Similar Artilces:

Client side to execute server side code
I am maintaining an ASP.NET C# application written by someone else.  I am essentially a newbie to web development especially client side stuff.  Based on reading these forums I understand that I can't directly call a server side method from the client side and I have to use post pack in some way (using a webservice is not an option here).  My confusion comes from the HTML setup being used.The page has three frames; a header, body and footer.  Each frame is filled by it's own ASPX page.  The footer contains buttons for navigating to another page and some of the b...

executing server side code and client side (javascript) code simultaneously while clicking a button
how to execute server side code and client side (javascript) code simultaneously while clicking a button in asp.net. You can't. When clicking a button: the client-side executes, the page does a PostBack, then the server-side executes.NC... what if i want to update a database and then open a new windows is it possible with Jscript.net?...

How to get the Client side values in server side code.
Hi all, i have a proble i need to get the client side javascript values in C# code at server side. how can i pass those values? i am using version 1.1, i kno thatwe can use callback events mechnisam in 2.0 or ajax ,apart from that how we can pass? My problem is i need to stop the execution of the code based on after reciving values from the client   any ideas please???   Million thanks RamCheersRam MCP Hello Ram, a common approach is from javascript set an hidden field, then issue a postback. On the server-side, handle the post-back. Feel free to go deeper in your que...

I need to get a server side button to run this client side code?
I need to get a server side button to run this client side code when the server button is clicked and then subsequently called by the server. Is it possible? The problem is that the print control is a client side activex. I can call it normally using a client side button but this is no good when I need to print more then one page. Any help would be great. Thanks. The code: function PrintProc(){ var MyPrinter; MyPrinter = new ActiveXObject("ImgXPrint6.ImgXPrint"); MyPrinter.PageFrom = 1; MyPrinter.PageTo = 1; MyPrinter.PageM...

client side code & server side code
what is the difference between client side coding & server side coding ? when to use client side & server side code? Client side code runs on the user's browser and includes languages such as javascript and vbscript. Server side code runs on the web server and can be written in languages such as ASP.NET, PHP, ASP, ColdFusion etc. Website Design Darlington - http://mdssolutions.co.ukhttp://lessthandot.com - Experts, Information, Ideas & Knowledgehttp://aspnetlibrary.com - An online resource for professional ASP.NET developersPlease remember to click "Mark as Answer...

How to execute server side code using VBscript bcz i need at client side.
How to  execute server side code using VBscript bcz  i need at client side.Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim strSCript As String = "<script language=VBScript>Call load_LF()</script>" If (Not ClientScript.IsStartupScriptRegistered("clientScript")) ThenPage.RegisterStartupScript("clientScript", strSCript) End If End Sub here i am calling the vb script function i.e <script type="text/vbscript" language="vbscript"> sub load_LF() myclass....

client side and server side code
Making things clear:When creating a web application one must know the difference between client side code and server side code.client side code is the code that is executed on the computer of the user. server side code is the code that is executed on the ....server.why is there client side code and server side code?well... server side code exist for the reason of sharing data with multiple users. for example: accessing a database.ASP.NET is a server side technology. in ASP.net you can use different languages such as VB.NET or C#.client side code is used to perform tasks on the computer of th...

Calling server-side code from client-side
Hi,  I´m implementing some shortcut functionality in my web forms and wanna know where i can find something that explains, for example, how to call the handler event "onclick" of a button. I´m using this library to add shortcuts to my controls: http://www.openjs.com/scripts/events/keyboard_shortcuts/   And I want to "link" some key combination for the event handlers of the controls. Does anybody knows?  Thanks. You could attach an AJAX event to the Javascript shortcut event handler so, for example, the shortcut function will trigger a button cl...

javascript execution after side server side code
I have a dropdownlist selected change event (server side). I need to execute a java script code after that server side event. how to achive this ?? I used Response.Write("<script>alert('hi')<script>"); . but its not working and all the form alignment was getting disturbed. is their any other way to achice this??     ThanksPrashanth.J Use RegisterClientScriptBlock method to execute javascript methods "at server-side"May the Force be with you Never use Response.Write except in debugging situations, because it will mess ...

Server-side execution vs. client-side
Hello, I am doing aspx web programming using vb asp.net in MS Visual Studio.  I am trying to make my program to when the user clicks on a button that my program launches another software package that we own (in this case the other software package is called Syteline).  The way that I am trying to accomplish this is via the CreateObject function route.  My program is running on the web server.  While I am sitting on the server that contains this Syteline application, I open up Internet Explorer and launch my web program.  When I click on the button, it gives me ...

How to Excecute Server side code in Client Side
I have a Textbox with linkButton on right side.  if i click linkbutton i have one text box agian in poup. if we enter some text and click search button i am showing ListView with searched data in Poup. the Listview contains one Radio Button at eash row. Now my request is if i select one radiobuton and click "OK"  the poup should close and display the selected row text in TextBox in my Page where the Linkbutton Presents. i can do it on my server side on "Okbutton_Click" . i wabnt to do this in Client side only with out PostBack.   Is ther...

Getting my client-side variable over to server-side
Ok so I have looked at a few posts on this subject and I can't quite figure out how to apply the idea to what I am doing here. I am using javascript to take amounts from 7 different textboxes and add them up on the fly, dropping the total in the 8th textbox. After they fill in that information they click button (postback) to continue throughout the form... what I need is for the "textboxTotalAmt" to move from client-side to server-side.  So I can access that total amount later in the form. Here is the Javascript piece... <script type="text/java...

How to Pass Information from Server-Side Code to Client-Side Code in AJAX Control Extender?
Hi All,For some reason I can't get the following to work: I have a custom AJAX Control Extender with a few getters and setters. I also have some images I want to use with the extender saved in a resource file. How to I make the respective image URLs available to the javascript of the extender? Are there any examples available?Thanks![Update: renamed the subject to something more appropriate.]  Perhaps I can clarify a bit:I have set up a getter and setter to set the image URL from the resource file: 1 [ExtenderControlProperty] 2 public string CoverURL 3 { 4 get...

Firing both Client side event and server side event for server side button
I am having some difficulties getting this to work.. I have button_click (Asp.net) and ClientClick (Javascript).  Javascript is firing fine.  Server script is not. may be you have return return false in the in the javascript which is why its not firing server side event.You should add javascript evelt like thisbutton1.onclientclick = "functionname" Function should nopt return false. Vikram www.vikramlakhotia.comPlease mark the answer if it helped you...

Web resources about - Execute the client side and server side code - asp.net.getting-started

Execute (album) - Wikipedia, the free encyclopedia
Execute is the debut album of So Solid Crew members, Oxide & Neutrino . It includes the Casualty sampling number 1 single " Bound 4 Da Reload ...

eXecute by J.P. Morgan on the App Store
Read reviews, compare customer ratings, see screenshots, and learn more about eXecute by J.P. Morgan. Download eXecute by J.P. Morgan and enjoy ...

Occupy Wall Street Protester Wants To Execute "White Collar Criminals" - YouTube
A protester at Occupy Wall Street tells National Review's Charles C. W. Cooke that he wouldn't want to be president because of his "dark side," ...

Taliban gunman publicly executes woman near Kabul
A man, Afghan officials say is a member of the Taliban, shot dead a woman accused of adultery in front of a crowd near Kabul, a video obtained ...

How Indonesia will execute death row inmates
Bali Nine drug traffickers Andrew Chan and Myuran Sukumaran will have some small choices in the way they die and those who execute them will ...

Pakistan to execute 500 terror convicts
Pakistan plans to execute about 500 militants in coming weeks after the government lifted a moratorium on the death penalty in terror cases following ...

North Korea 'executes' leader's ex (00:47)
According to South Korean reports, the ex-girlfriend of North Korean leader Kim Jong-un was put to death on pornography allegations.

Mentally ill Brazilian Rodrigo Gularte fit to execute: Indonesia
A Brazilian man whom the Attorney-General has proclaimed fit to execute with the Bali nine organisers was first diagnosed with a mental illness ...

Somalia executes Aden Sheikh Abdi for the murder of journalist Hassan Yusuf Absuge
SOMALIA has executed a man who was convicted of murdering a journalist, a military official said, the first such execution in a country where ...

IS 'executes' Chinese, Norwegian hostages
... to be Chinese hostage Fan Jinghui and Norwegian Ole-Johan Grimsgaard-Ofstad. A stamp-like caption overlaid on the full-page photo read: "Executed ...

Resources last updated: 12/27/2015 11:46:09 PM