Change value of textbox based on value from dropdownlist using ajax?

Hello,

I want to program an aspx form so that depending on what value you select from a dropdownlist, a textbox gets populated using ajax or javasciprt (client based)

I did this already server-side by reading from an SQL data table, but it's annoying because of the page refresh, anyway to do the same thing using ajax or javascript? Look at my code below:

 

Many thanks ! :)

 

Sub ddllocations_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddllocations.SelectedIndexChanged

Dim strconn As String

Dim myConnection As New SqlConnection(strconn)

strconn = ConfigurationManager.ConnectionStrings("CultureListings").ConnectionString

Dim CommandText As String = "SELECT address from locations where location = '" & ddllocations.SelectedValue & "'"

myConnection = New SqlConnection(strconn)

Dim objDR As SqlDataReader

Dim myCommand As New SqlCommand(CommandText, myConnection)

myConnection.Open()

objDR = myCommand.ExecuteReader()

objDR.Read()

txtAddress.Text = objDR("address")

objDR.Close()

myConnection.Close()

End Sub

 

 

 

0
asafblasberg
12/24/2005 4:49:04 PM
asp.net.client-side 24353 articles. 1 followers. Follow

1 Replies
994 Views

Similar Articles

[PageSpeed] 23

Since you have to make a call to your code, I recommend you use MagicAjax if you want to avoid the page refresh cause by postback. Please see the below blog entry on my blog that shows how to use MagicAjax.

MagicAjax - Easy as 1, 2, 3


Ryan Olshan
ASPInsider | Microsoft MVP, ASP.NET
http://ryanolshan.com

How to ask a question
0
StrongTypes
12/25/2005 1:10:01 AM
Reply:

Similar Artilces:

Issue obtaining values in server-side from dropdownlist when updating value using client-side script in master page
HiI got a page in a contentplaceholder of a master page. There is two pulldowns. I populate the first one using server side coding and then use client-side javascript. So far so good. The issue is that upon a postback I try to collect the select value of the second pulldown and there is no data in the pulldown and no selected item. I tried using control.selectedvalue (nothing) or searching the form controls Stringvariable = oForm.FindControl("Control")Thing is I've done this before in 1.1 outside of a master page and it works.Thanks in ad...

Change value of textbox dependent on value from dropdownlist
How do you achieve this but client-side, to avoid the constant page refresh? (Javascript)   Best, Asaf. You need to use an onChange event on your DropDownList and wire it to a JavaScript function. In the code example below, ddlID and txtID are the control IDs of your DropDownList and TextBox controls. Code: ddlID.Attributes.Add("onChange", "setText('" + ddlID.ClientID + "', '" + txtID.ClientID + "');"); JavaScript: function setText(ddl, txt){   var ddlID = document.getElementById(ddl);   var txtID = document.getElementById(txt);   &...

TextBox values check with dropdownlist values using javascript
 Hi,I have a Textbox and dropDownlist.I am showing database values into the dropdown list.When user enters something into database. And if entered value is existing in the dropdownlist alert should give as 'This value already exists.'This i want to do using javascript.I need it very very badly.Please reply.thanks   for(var vLoop=0; vLoop<document.getElementById("<% dropdownlst1.ClientId %>").options.length  ; vLoop++){         if(document.getElementById("<% dropdownlst1.ClientId %>").opt...

how to change the value of checkbox when i change the value of textbox
i want the checkbox to change its value to unchecked when the textbox doesnot have anything i.e is value is "" and as soon as i enter anything to it, the checkbox should automatically change to checked. Can you please tell me how to do this Add to the textbox: OnKeyUp="CheckValue()" Add to the html: <script language="javaScript"> function CheckValue() { if (document.getElementById('textboxid').value.length == 0) { document.getElementById('checkboxid').checked = false; } else { document.getElementById('checkboxid').checked...

Using hidden field to store value then calling that value from client side
I have three tabs (1,2,3) on my main page each tab contains a datagrid... when a user select a tab then leaves the main page and returns to that main page(without exiting browser) I need for the page to open with the tab last selected by that user so that they can pick up where they left off. No one can seem to help me with this issue.... My javascript (client side) code function is as follows: <asp:HiddenField ID="hdnNewPanel" runat="server" /> <script language="javascript" type="text/javascript"> &nb...

to change value of Client Side Select html control from database value....
hello forum,  I have a select .. Demo.aspx <select id="DropAccType" name="DropAccType"> <option>Select</option> <option>Saving</option> <option >Current</option> <option>Regular</option> <option>Demat</option> </select> I want to set the value of select by fetching the data from daabase i.e. In my table if I have Value current then when i request the demo.aspx then in select Control the value Current should get selected..... Please help me to sort this out...   Thnx in advance.. Hi-I could be...

Accessing values on the server for controls whose values were changed client-side
Let's say that I have two server controls, a label and a textbox: <asp:Label ID="Label1" runat="server" Text="Old value"></asp:Label> <asp:TextBox ID="TextBox1" runat="server" Text="Old value"></asp:TextBox> Then I run some client-side code that changes their values: document.getElementById('Label1').innerHTML = 'New value'; document.getElementById('TextBox1').value = 'New value'; In the browser, they both visually have the value "New value".  Howev...

I want to display textbox on changing value of dropdownlist or selected value of dropdown list.How could i?
for example i have taken field PF%,PF($)  in dropdown.Onselected value of % i will show textbox.In which u can fill  the value of PF% based on that calulation will be shown in other textbox. But how can i do thta? Not too sure I undertand your question, but if you want to show/hide elements here's a few things you might want to try: You can set the dropdown's autopostback to true and perform all sorts of wonderful serverside stuff, including adding a textbox control (with a certain value) to a container div. If you want to keep things light then use some CSS and ...

Change Another Column Value based on Dropdownlist selected value while gridview onrowediting
Hi everyone. Another gridview question again. I have a gridview, with three columns, Code, Description and Action. The Code column, when I click on the Edit linkbutton on the Action column becomes a dropdown list. How can I do that when I selected a value from the dropdownlist, the value of the description on would be changed to the description corresponding to the dropdownlist? Thanks.   Hi:   From your description I think you can try: 1. Set AutoPostBack=true for your DropDownList. 2. protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) &n...

how ontextchanged event in datalist fire and when that textbox value change than another textbox inside datalist value also change
 i have one datalist into which i used maskededit extender for time entry there is three textbox (1) start_time (2) end_time (3) duration so when enter  end_date value than this text box ontextchage event fire and duration will automatically calculate by(end_time - start_time) and display into datalist duration textbox. in datalist there is more than one item.i put some code so just check  <asp:DataList ID="CONTRACT_SERVICE_ITEM" runat="Server" RepeatColumns="1" RepeatDirection="Horizontal"      &nbs...

How can I handling dropdownlist value changed on client side
Hi,I want to verify that the user really meant to change a field that is displayed as a drop down list, but only part of the time based on the original value of the field.  For performance reasons I prefer to do this with javascript on the client.  However, I cannot figure out how to wire you a client side event handler for the value changing. I was hoping to be able to use the OnChange event of the underlying Select. Any thoughts? jerry Hi you can use a CustomValidator1  and ClientValidationFunction="yourjavascript function"   <asp:Drop...

Newbie with Ajax
I have a usercontrol with a grid and label on it which is inside an update panel that is loaded dynamically.  When a selection on the grid happens (client side) the label value gets updated.  But when I try to reference the label from the parent page.  I get the original value of the label and not the updated value.  For example:  If I had a label and the value was originally set to "Test" and when I select a value on the grid, the label changes to "1515".  When I try to reference it from the parent page, I am still getting "Test&qu...

Get the Dropdownlist text and value using Javascript from client side
Hi, I am encountering a problem about how to get the Dropdownlist text and value using Javascript from client side. I am using C# in Visual Studio 2005 and Javasript . The example codes are like: ( In this example code, I would like to access the text and value of the DropDownListReports in the run() function of Javascript. How can I do that? Any ideas? Thanks a lot. ) protected void Page_Load(object sender, EventArgs e) {              if (!Page.IsPostBack)            &nb...

How can I set client side values as server side values?
Hi, Can anyone tell me how I can get client side values such as document.referrer, navigator.appName etc... into server side scripts? There are some client side values I'd like to set as session vars and insert into the db? How do I go about this? Thanks for any pointers Davlon PS (I'm using powersite 7.1.0.300) Pass them as page parameters, e.g., http://myserver/myurl?document.referrer=whatever&navigator.appName=yadayada Then, in your server-side script, just loop through the document.value array and get these values. -- pbm_hopethishelps, Roy Kie...

Web resources about - Change value of textbox based on value from dropdownlist using ajax? - asp.net.client-side

Tag Synonyms - Stack Overflow
Q&A for professional and enthusiast programmers

Accidental entities - what about the UI?
This post is a follow-up to my previous blog post " Accidental entities - you don't need that identity ". In that post, we followed a consultant ...

Flash Builder Plug-in for SAP Netweaver Gateway - Adobe Labs
Search Navigation Labs Home Wiki Home Technologies Alchemy Blueprint Camera Profiles and DNG Profile Editor Cirrus ColdFusion 10 DNG Codec Fireworks ...

Air Astana - Join Now
Thank you for considering membership of Nomad Club – Kazakhstan’s first Frequent Flyer Program. You could soon be on your way to earning free ...

Languages -> C# Articles, Tutorials, Examples: ASP Alliance
.NET,ASP,ASP.NET,SQL,XML,HTML,ADO,ADO.NET,JavaScript,JScript,CSharp,VBScript and VB tutorials from AspAlliance.

Blog - Avisra
Avisra Web Development Home Blog Services Contact The Blog Latest Module Builder: How can we make it better? Sitefinity by Chris on July 2, 2013 ...

Online Booking Tool Support
This Online Booking Tool Support page might help you as you navigate through the process of booking travel through your OBT provided by CWT. ...

@Html and beyond
... ); } return string .Format( “{0}{1}” , me.Member.Name, id); } The Html building methods are quite simple. Building a dropdownlist for a ...

Top Ranked Articles
Top Ranked Articles - Free source code and tutorials for Software developers and Architects.; Updated: 23 Feb 2013

Unit Testing DateTime.Now Without Isolation
public virtual void SeedWithYearsSince(DropDownList list, int year){ for (int index = year; index

Resources last updated: 1/11/2016 3:13:02 PM