Jquery quering the db
-
Hey everyone, I'm currently updating a project that is to be honest a bit dated, Data access layer is in c# and screen tier is in vb(dont't ask me why). Anyway for validation you always need to postback to validate data an that, I have started using jquery (which is cool by the way) for validation and I have it working for general data i.e invalid lenght, characters etc...., I'm just wondering how to get jquery to connect to the db to see if say the name in the textbox already exists?? Cheers
-
Hey everyone, I'm currently updating a project that is to be honest a bit dated, Data access layer is in c# and screen tier is in vb(dont't ask me why). Anyway for validation you always need to postback to validate data an that, I have started using jquery (which is cool by the way) for validation and I have it working for general data i.e invalid lenght, characters etc...., I'm just wondering how to get jquery to connect to the db to see if say the name in the textbox already exists?? Cheers
I don't get it why you need to do this in jQuery, if you already have C# in the back-end... You would, either way, need to do a post to implement such request, and implementing it in C# is the easiest thing to do. Invoking C# action from jQuery is very easy, there are plenty of examples about it in the internet.
-
I don't get it why you need to do this in jQuery, if you already have C# in the back-end... You would, either way, need to do a post to implement such request, and implementing it in C# is the easiest thing to do. Invoking C# action from jQuery is very easy, there are plenty of examples about it in the internet.
Was kinda thinking when the page firsts loads that I could some way store the values that were in the db and then if the user entered one of those values that jquery would present the user with a message to say this name already exists. I already have validation working for valid emails, lenght etc..
-
Was kinda thinking when the page firsts loads that I could some way store the values that were in the db and then if the user entered one of those values that jquery would present the user with a message to say this name already exists. I already have validation working for valid emails, lenght etc..
Preloading the complete list of valid values probably isn't the correct approach; for one thing, it could be quite large, and for another, do you really want users to be able to see all the values in this table? Doing an AJAX lookup at an appropriate time (send something like checkValue?typed=whattheusertyped to a simple server-side script), i.e. when they tab out of that field or pause typing for half a second, or something like that, seems like a better solution to me.
-
Was kinda thinking when the page firsts loads that I could some way store the values that were in the db and then if the user entered one of those values that jquery would present the user with a message to say this name already exists. I already have validation working for valid emails, lenght etc..
Validation against pre-fetched values is a heavier operation than server-side validation. You should just go for the latter as a much better standard ;) It will be one short post instead of sending a whole list of records into the browser.