asp.net gridview ajax - asp.net

In Ajax,is there any technique exist to validate ASP.NET GridView, i.e., to check whether the GridView contains at least one row?
Any comments welcomed.

I assume you render the GidView on the page. If I get you can check it using Javascript/jQuery on client side...
If you want to check it on the server side you have to call a method on the .aspx page using Ajax. In this case you should create a static web method on the page that check how many rows the gridview has got then you have to call that method using Ajax or jQuery
http://www.singingeels.com/Articles/Using_Page_Methods_in_ASPNET_AJAX.aspx

Related

asp update panel and JSON with Ajax

i have a qeustion on design decision
i have a aspx webform that has two dropdownlist
one of them are set to autopostback in order to generate values in the second dropdownlist.
my lecturer told me that i can use json with ajax to improve the postback.
however i googled online and come across the asp updatepanel function.
i want to ask , does the two works like the same ? if i have to use json with ajax, do i have to write the page in traditional html instead of html with asp controls ?
what are the pros and cons to this two ?
Thanks,
WuSen
see this link What are the advantages of jQuery Ajax vs UpdatePanel or even you can find more here http://codingstill.com/2012/02/asp-net-and-ajax-all-about-update-panels-web-methods-page-methods-and-jquery/

jQuery ASP.Net Webforms AJAX

I have a standalone webform (no masterpage) that opens in a div from another page. The standalone page uses jquery to move a user through a non-linear questionnaire. At the end of the questionnaire there is a result displayed with a "complete" button. When the user hits the complete button the result is sent back to the parent/host page of the div.
I have a new requirement where i need to actually pass the question and answer id's to code-behind or web service where i can insert the question and answer id's to my DB.
None of what i need to do requires object serialization. I want to do this as simply as possible.. none of the controls in the questionnaire are server controls.. just regular select boxes or radio button groups. I suppose i could do an ajax postback using an update panel or something but not sure if making the controls runat=server will screw up all the jquery/js i have working in the questionnaire.
Any help is appreciated thanks!
I would tackle this by using jQuery to post the data to a web service, which is fairly trivial. There's are a couple of code examples for doing this with asp.net here:
jQuery: Ajax call to asp.net webservice fails, server return 500 error
and
Calling a webservice through jquery cross domain
To answer your other question, putting runat="server" will not have an affect of jQuery's ability to parse the elements in the DOM.

jQuery to bind data to ASP.NET DataList using a ashx handler

Using jQuery how do I bind data from a call to a asp.net ashx handler to a datalist?
Simple answer : You don't. A datalist is server side and jQuery is all local.
Complex answer : You can use jQuery to allow the user to interact with controls and displays locally. You can also use jQuery to update your data store (SQL). Then you can reload the data into a server side varable from the data store inthe code behind.

listview of ASP.NET(web application)

i have placed four textbox inside the listview of web application. if i enter data in first textbox, its corresponding record should be fetched from oracle database and fetched record should be placed in 2,3,4 textbox.
****TextBox.TextChanged Event
How to: Respond to Changes in a TextBox Web Server Control
Edit:
From your edit it would be better to use AJAX.
You can fetch data from oracle database from C# using the AJAX call and return the result to the response and display the data.
If you're using webforms you could use a WebMethod to invoke the query from javascript, you can see an example here.
You could also just add a control that invokes a function server side and use the FindControl method of the ListView to obtain the value of your textbox. Also if you want the function/method to be called when the user stops typing you could use a jQuery plugin called typewatch you can find it here. Also taking into account the WebMethod* attribute that I mentioned earlier in the answer.
Go through the article Complete ListView in ASP.NET 3.5. This article shows how to place textboxes inside listview and edit the data in listview.
For Oracle connection in ASP.NET this article Connecting to an Oracle Database Using ASP.NET—A Step-by-Step Tutorial will definitly helps you

Using JSON or postback method?

I need to develop a page which has 2 dropdownlist.
Options of dropdownlist 2 are based on selection of dropdownlist 1.
I have 2 methods to change the dropdownlist 2. What will you choose?
1:
Postback when users select dropdownlist 1 and change dropdownlist 2.
Pros:
Can use the postback feature, can use the asp.net validator
Cons:
Need to communicate with server (more traffic)
Users will see the page loading in the status bar.
2:
Get all the data (not very much data) in a JSON object when loading the page and change the dropdownlist 2 using javascript.
Pros:
Don't need to communicate with server(less traffic)
Cons:
Can't use the postback feature and validator and more troublesome to write server validation.
Also, I usually write the JSON object to the page as follows:
var locations = <asp:Literal runat="server" id="litLocation" text="[]" />
And then set the "litLocation" in page_load after the data is processed by datacontractjsonserializer.
Do you do it in the same way?
I prefer the second option, no need to reload the whole page just to refresh one dropdown list. I'd also do the client side dev in jQuery, much easier. You can do the client side validation for the change event of the first dropdown in jQuery as well, and keep the form submit validation in ASP.NET.
Have a look at the selectChain plugin for jQuery (demo's etc here).
Why not have your javascript call the server when the select box is clicked on, using a GET method, and fill in the select box, using json as the response, then, when an option is picked then fill in the second select box with another ajax request.
This would be scalable, in that if you want to add more options you just change the server, and everything is centralized.
You will need to validate when the form is submitted anyway, as it is possible to change a value of a form to something illegal using some debugging tools, such as Firebug, so never trust anything from a webpage until you have validated it.
So, no point worrying about the validation until the form is actually submitted.

Resources