Asp.NET html <button> element onclick and onserverclick -> client-side validation

The problem solved here is that an asp.net <button> element (html = <button runat=”server” > or <asp:HtmlButton )  doesn’t support a onclientclick event. This prevents performing client side validation ahead of the onserverclick event.

Here’s more on the problem.

http://stackoverflow.com/questions/1245033/asp-net-onserverclick-event-handler-not-called-if-using-onclick

Continue reading “Asp.NET html <button> element onclick and onserverclick -> client-side validation”

Telerik ASP.NET MVC – Count the number of elements in a Combobox / DropDownList or AutoComplete UI component

Quick Answer

 

Intro

I had this desperately annoying problem where I had two Combobox components. Using the .CascadeTo functionality, I was able to have the second Combobox load data via an AJAX call based on the selection in the first Combobox. This is standard functionality detailed in the demo site here.

The problem was that if the AJAX call to load the second comboxbox with data returned no elements, the Combobox remained disabled. This was unintuitive for the user and made it look like the UI had frozen.

The solution:

  1. Add an ‘OnDataBound’ event handler to the Combobox then from this…
  2. …. count the number of elements in the Combobox and do something to notify the user if there are no elements

Continue reading “Telerik ASP.NET MVC – Count the number of elements in a Combobox / DropDownList or AutoComplete UI component”

.NET MVC 3 Custom AJAX Error Handling

Custom Message From AJAX Error Handling with jQuery and MVC 3
Custom Message From AJAX Error Handling with jQuery and MVC 3

An exception on the server-side will invoke the JavaScript AJAX error handling function. This blog will detail two methods to provide custom error handling, overriting the default.

Both methods allow specific error messages to be returned to the client error handling code. This example applies to .NET c# MVC 3 with jQuery and jQuery form plugin. Before quickly scanning this blog for the solution, please note that the second solution detailed below appears to be a better option.
Continue reading “.NET MVC 3 Custom AJAX Error Handling”