ASP.NET WebForms and jQuery Validation - validate() undefined - c#

I thought the entire purpose of jQuery was to make a developer's life easier but ever since I started learning how to use it ~3 months ago it has caused nothing but nightmares for me!
I'm now working on an ASP.NET WebForms app and am trying to use jQuery Validation since the built-in validator controls can't be easily rendered below their input counterparts. That is all I want to do; have an input with an error message that dynamically appears and disappears underneath it, but I've been banging my head against a brick wall for 5 hours trying to figure out how to do one, seemingly-incredibly-simple little thing!
I started off with a bunch of <asp:RegularExpressionValidator> and <asp:RequiredFieldValidator> controls (since you can't do both validations with one control) but didn't like how the error messages displayed inline, to the right of my inputs. So I spent ~2.5 hours trying to make ASP.NET render the damn things with display: block;, to no avail.
That's when I remembered a colleague having mentioned the jQuery Validation plugin to me about a month ago...so off I went trying to implement a solution with that. But no matter what I try, Google Chrome v.41 on Windows keeps giving me an "undefined is not a function" error on the jQuery.validate() function.
I know what you're thinking: something along the lines of "ASP.NET mangles control IDs...yada yada yada", but I've been using <pages clientIDMode="Static" /> in my web.config's <system.web> section ever since I started this project, so that's not the issue. I'm also 99.999% sure that I'm including the necessary scripts in the correct order, even though some are included in my master page and some in the content page (this shouldn't matter, should it?)
This post is already way too long, so check out the full code here.
MTIA to anyone who can tell me what the hell is going on here!

I debugged your code. The problem is with your comments. Remove your comments from the code, and it will work :)

Related

Adding User Controls To Web Page in VB.Net Web App

I have followed the setup instructions at this link Adding Controls to a webpage
However, for the 2 weeks that I have been studying vb.net, I have yet to be able to add a drag and drop form or control element on the page as all options are grayed out...even while in design view. Is there a setting I am overlooking? It doesn't make any sense that there would be tutorials on how to do the exact thing I am trying to do, but for some reason, it does not allow me to do it on my setup. Please help!?
Ok...rookie mistake. I figured it out. I was still running and debugging the application. Must stop the application from running and then all form controls become "addable".
Hope this saves someone time.

Facebook Like/Send buttons inconsistent across site pages

I have implemented the Facebook Like and Send button plugin. Look I think its fair to say that this should be fairly straightforward and having stepped though the process I was very happy that this was the case.
I am having an issue now that is causing me some difficulty resolving.
The issue is around an inconsistent display and functionality of the plugin. It works perfectly for some of our site pages and doesnt work at all for others.
On the pages where the plugin does not work the Send Button doesnt appear and when the Like Button is clicked it opens the Like Dialog very briefly and immediately closes it without any Like Action being recorded
I have checked all of the site pages through the Facebook Debugger tool and all the pages are being scraped correctly with correct Open Graph Meta Tags etc...
At this stage I am wondering if anybody has had this issue? I am aware that there were issues with the Send Button this year but my understanding was that these issues had been resolved...
website url that displays incorrectly is: http://www.todaysdeals.ie/Deal.aspx?dlid=441
website url that displays correctly is: http://www.todaysdeals.ie/Deal.aspx?dlid=439
It looks to me like the problem is in how you're declaring the button code. You've specified a width of 90px in the FBXML code, but Facebook seems to be ignoring this and rendering its code at 150px.
My guess is on the incorrect page, you've got a large number of likes on this page, and it's wrapping the buttons into a hidden area of the div.
I'd start by increasing the width in your FBXML code to at least 176px and see what happens.

AjaxToolKit - Extender controls may not be registered before PreRender

i am trying to the MaskedEditExtender and MaskedEditValidator to work.
im not getting any type of error; however the maskededitextender or validator are completely not working.
the question is exactly similar to:
ajaxtoolkit maskededitextender not working
ive downloaded a sample of the maskededitor from the asp.net site and running the code exactly as is.
what am i doing wrong?
if you think jquery is better for this please do send me an example!
I must say that it's been long time that I have used the Ajax Toolkit as I started to use more and more jQuery and understand Javascript better, I realized that Ajax Toolkit was creating to much code for really simple things.
My suggestion goes to use a jQuery Plugin as you probably are already using jQuery for something else.
start with this really simple tutorial:
http://webdeveloperplus.com/jquery/how-to-mask-input-with-jquery/

How to alter browser's back button functionality similar to eCommerce sites in asp.net

I have a web application, in which browser's back button functionality should be customized. It's like, whenever we click on browser's back button, it should take us to landing page(Login page), It should display error message saying that 'session expired. Please login again'.
I have gone through so many posts and even in stack overflow also, i saw few posts. But nothing worked for me. The java script approach i am using as a temporary workaround.Basically this JavaScript never allow us to go back. instead it will keep us in same page.
JavaScript i have used <script>history.go(1)</script>
Please help me to customize the functionality of Browser's back button.
Any suggestions will be really helpful to me.
Short answer: You cannot
A little longer: You shouldn't even try.
But if you insist: A Thorough Examination of "Disabling the Back Button." (from 2000, but since it is ASP I guess still valid for you :)
Newer dot net: Restrict user go back to previous page after signout
Ignore the older browsers do not support location.replace - IE3.2 is not considered older any more but ancient.
For this - you would need a custom solution and disabling back button will not help...
Usually you should not try to change the behavior of back button. But since this is the requirement, I would suggest the following:
Approach 1:
This calls for creating a navigation framework where you know which is the current page in the flow... This is only possible if you a sequence in which the pages will be called (like a wizard)
Approach 2:
Specific to your case : You can use jquery/javascript to identify if the back button is clicked.. If it is then you can do an ajax call to server to kill the session and then redirect the user to login page.
You can programmatically manipulate browser history using something like this:
window.history.back();
window.history.forward();
window.history.go(2); etc.
In HTML5 ready modern browsers like Chrome you can also do more advanced things including completely overwriting back button functionality using history.pushState() and history.replaceState() methods.
(https://developer.mozilla.org/en/DOM/Manipulating_the_browser_history)
You can also go dirty and use javascript + ajax calls to react specifically to back button events, but this will also not work on some browsers. What you ask is not a native part of a web, so no matter what you will decide to use in the end, it wont be very easy or widely supported.

Silverlight: Auto scrolling page when tabbing to different textbox

I am using silverlight 2.0 with C# for my application.
Few of the pages are quite long and contain quite a few of textboxes. The question I have is:
I use 'tab' to move between the textboxes on the page. When I tab into a TB that is not shown on the page - how can I make it so that the pages autoscroll to display which field I am on the page?
Right now I have to manually scroll the page. I have tried couple of things and would like to know if there is an easier more efficient way to accomplish this.
Thanks in advance!
Here is a behavior that looks good for the "scroll into view" issue. I haven't tried it myself though, so I cannot vouch for the quality (and I don't know if it works in Silverlight 2):
Silverlight BringIntoView() extension method (with OnGotFocus behavior)
And I very much recommend migrating to Silverlight 3 (and later this year, 4) if you are planning on doing more work on the application. It is hard to say how difficult it will be for you, especially since you are new to Silverlight. That depends on the nature of your application. I can only say that when we migrated from 2 to 3 it was not that difficult, and we have a big application with a lot of strange hacks. I was expecting a world of pain, but it was done in a couple of days. Oh, and you can get the Telerik components for version 3 as well.
I would suggest that you try compiling the app in Silverlight 3 with the upgraded Telerik components and see how many build errors you get. Then you will probably have a pretty clear indication of whether it's worth it or not.

Categories

Resources