aic007 Posted April 12, 2007 Share Posted April 12, 2007 Hi.I'm very new with ASP (and C# also), so I thought I could ask some experts here for help I was wondering if sombody here could tell me what to do in order to get one or more textboxes to retrieve information automaticly ?For instance, if I type in the employee nr, I want the name and adress textboxes to be filled in automaticly.I really don't know how to do it. Can somebody plzz help me or show me some examples ? Link to comment Share on other sites More sharing options...
jesh Posted April 12, 2007 Share Posted April 12, 2007 In order to populate those fields with data from some data source (e.g. a database), you'll have to make a call to the server. The easy way would be for the user to type in a value into the employee ID box and hit submit to post the request back to the server. Then, on the server, check that value against the data source and populate the other two text boxes with that data and send the response back to the user.A more challenging way is to use AJAX to send that request to the server so the user doesn't have to submit the entire page.This article (http://www.codeproject.com/aspnet/GoogleSuggestDictionary.asp) may help get you started. Link to comment Share on other sites More sharing options...
aic007 Posted April 12, 2007 Author Share Posted April 12, 2007 Thanx a lot man.. I'll take a look... Looking quite difficult for a newbeginner though Link to comment Share on other sites More sharing options...
jesh Posted April 12, 2007 Share Posted April 12, 2007 It's not too bad if you take it one step at a time. First, you might figure out where that data is going to be coming from. If it's going to be coming from an XML file, then you'll want to look around for some tutorials about how to load XML files and read their data.If it's going to be coming from a database, check out how to set up databases. Once the database is set up, look for tutorials about making a connection to the database and retrieving data.Projects are definitely difficult and confusing when you first approach them, especially when you are learning a new technology. Just take it one step at a time and you'll get there. Link to comment Share on other sites More sharing options...
aic007 Posted April 12, 2007 Author Share Posted April 12, 2007 Thanx mateI have managed to connect to database and retrieve information. Now I have to, as you also said, find a way to retrieve the data the way I want. Open for all suggestions Link to comment Share on other sites More sharing options...
jesh Posted April 12, 2007 Share Posted April 12, 2007 Well, if you want to go the easy route:.ASPX <form runat="server" id="UserForm"><asp:TextBox id="EmployeeID" runat="server" /><asp:Button id="SubmitButton" runat="server" OnClick="SubmitButton_Click" Text="Submit" /><asp:TextBox id="EmployeeName" runat="server" Visible="false" /></form> .ASPX.CS protected void Page_Load(object sender, EventArgs e){}protected void SubmitButton_Click(object sender, EventArgs e){ int _employeeID; int.TryParse(EmployeeID.Text, out _employeeID); // _employeeID now has the integer value of the employee id // entered by the user. Use that integer to get the data from the database // once you have the data you can set the value to your EmployeeName text box: EmployeeName.Text = _employeeName; EmployeeName.Visible = true;} If you want to go the AJAX route, head over to the AJAX tutorial here: http://www.w3schools.com/ajax/default.asp Link to comment Share on other sites More sharing options...
aic007 Posted April 13, 2007 Author Share Posted April 13, 2007 Yeeay.Thanx a lot man Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now