So here is the situation. I am originally a PHP developer, here are my steps to render data:
- PHP gather data from DataBase
- PHP write data to JavaScript
- JavaScript render using JQuery to HTML
- HTML display to user
- User Postback to PHP
- PHP write back to Database with new data
Now I am using VB.NET and I need to use their paradigm with controls and what not. However I would like to render using JQuery and JavaScript. How do I get data into JavaScript when loaded in VB and get it back once user post?
- VB gather data from DataBase
- ???? (NEED HELP HERE: How does VB write data to JavaScript in this step)
- JavaScript render using JQuery to HTML
- HTML display to user
- ???? (NEED HELP HERE: How does user Postback to VB in this step)
- VB write back to Database with new data
Now, I know I can create my own control and write custom render function, but that would take way too long and so this solution is out.
The answer to both questions really depends on the specific situation you are in. You can use methods on ClientScriptManager if you want to spit out pure javascript code on your page. The 2 most useful methods are
RegisterClientScriptBlockandRegisterStartupScriptOr, the approach I would follow if you are using JQuery + Ajax, would be to implement WebServices that return data in JSON format. This blog has very good examples of how to achieve this.