So, I am pretty new to web programming and I just understand the basic syntax, not too many advanced features or anything. Also, I really don’t have any experience with Javascript, but again I pretty much understand the syntax and general programming knowledge from my experience with C++, so I can probably figure it out.
Here’s what I’m looking to do. I have a web service that returns a DataSet variable/array/data structure. Since this is a .NET type, I figured it would be easiest to access this service with ASP.NET as well. I can read the data in from the web service and display individual elements by specifying table, row, and column, so I know the data is there. However, I want to display the results in a table. I did get this to work(I don’t have the code with me right now, however) but only when the page first loads. The web service method I am accessing performs a SQL query, and I want to be able to type in the query string into a text box, submit that to the server, and have it update/populate/create a table. I’m sure this is very simple, but like I said I’m just really new to web programming.
I remember seeing a page on w3’s tutorial site that used the “Web Pages” syntax inside an HTML table, and used a foreach loop to iterate through, create the new rows, input the data, etc. I understood that, but I’m not sure how to accomplish something similar with the “Web Forms” type of project(I’m stuck using visual studio or notepad++ since I’m doing this on my work PC, and I think the .cshtml files use a different editor)
I’m thinking either some form of inline code, or modifying an HTML element from the C# code (within the codebehind file) or using inline code within the HTML element itself. I’m not exactly sure how to write an event handler in ASP.NET, can you use an HTML form/button to call an ASP.NET function(again, which is within the codebehind file)? Also, sorry if something similar has been asked, I’m going a little crazy since I’ve just learned all this web dev stuff over the last week! Btw, can someone explain what happens to the ASP.NET elements when they are returned to the browser? Does the server basically convert them into basic HTML elements? The application I am working on will be used on mobile devices so it needs to be as simple as possible on the client side.
Thank you.
You should be able to do what you are looking to do in an ASP.NET application without too many headaches. You should be able to add the controls to your page and then call the web service on postback.
Is there a reason the results have to be bound in inline code? If not why not look at using an ASP.NET gridview or a Data Repeater Control. You can add the controls to the web page and then bind them in code behind once you have retrieved the values from the web service.
With the gridview you should be able to just set the columns you want visible, set the data source and then call data bind. When rendered to the browser this will appear as a HTML table.
With the repeater control you will have to do a bit more work to setup the item template but it should also work for you.