adsense

Wednesday, October 31, 2012

IsNumeric function for c#

In VB.Net there is a useful function to check numeric data which is not available in C#. Here I m showing the IsNumeric function  for c# which can be used to achieve the same result.

bool IsNumeric(string strValue)
        {

            try
            {

                double doub = double.Parse(strValue);

                return true;
            }
            catch
            {

                return false;

            }
        }

Cheers
Samitha

Tuesday, October 30, 2012

Virtual Keyboard for asp.net

There are several occasions where  might be concerned to give maximum protection to user inputs (i,e. Password input). This can be achieved by integrating a simple virtual keyboard for your interface. Listed below are some of the free resources which you can try.

http://www.opensourcescripts.com/info/javascript-graphical---virtual-keyboard-interface.html

http://www.dotnetobject.com/Thread-Google-Virtual-Keyboard-API-with-javascript-asp-net

http://www.codeproject.com/Articles/13748/JavaScript-Virtual-Keyboard

Cheers,
Samitha

Friday, October 26, 2012

asp.net text box highlight text on click

Sometimes you might have come across in situations where you need to select all text in the textbox on click. There can be many other ways to do this but here I've used jQuery to achieve this.


<script type='text/javascript'
src='../Scripts/jquery-1.3.2.min.js'>
</script>
<script type="text/javascript">
$(function() {
$('input[id$=txtBoxName]').click(function() {
$(this).focus().select();
});
});

This script  work on all leading browsers.

Cheers
Samitha

Wednesday, October 24, 2012

Load javascript file via code behind

Sometimes the javacript file loaded in the header section seem to be unloaded during the page post backs. The trick is to register the file with ClientScriptManager  as follows.


protected void Page_Load(object sender, EventArgs e)
    {
        if(!this.Page.ClientScript.IsClientScriptIncludeRegistered("qry"))
            this.Page.ClientScript.RegisterClientScriptInclude("qry", ResolveClientUrl("~/js/YourScript.js"));
    }

Regards
Samitha

Tuesday, October 23, 2012

Working with button OnClick() and OnClientClick()

When we want to check some client side validation on a buttons' click  OnClientClick() comes to your assistance. But it seems that using OnClick() and OnClientClick() events at the same time bit tricky.

I have tried following ways, but none of them worked..!!

OnClientClick="return ValidateFunciton();" OnClientClick="if(ValidateFunciton()) return true;"
OnClientClick="ValidateFunciton();"
 
But following worked for me
 
<asp:Button ID="btnSearch" runat="server" Text="Search"  
OnClick="btbSearch_Click" 
OnClientClick="if (!ValidateFunciton()) { return false;};" />
Cheers
Samitha
 
 

Saturday, October 13, 2012

opensource rich text editor for asp.net

"CKEditor" is the best WYSYWIG editor that can be used for asp.net. For more details check here.

In addition AjaxToolkit also provides a HtmlEditorExtender which takes advantage of HTML5 and supports IE 6 and later and other leading browsers. Check more details here.

Edit
. Refer this article for an excellent example of using HtmlEditorExtender. You might face some configuration errors (i.e. Unrecognized element 'sanitizer'.    ) when setting up this control.

Change web.config as follows to overcome this error.
  <configSections>
 <sectionGroup name="system.web">
      <section name="sanitizer" requirePermission="false"
               type="AjaxControlToolkit.Sanitizer.ProviderSanitizerSection, AjaxControlToolkit" />
    </sectionGroup>
  </configSections>

The first entry in <system.web> section shoud be chaged as follows
<trust level="Full" />
  <sanitizer defaultProvider="HtmlAgilityPackSanitizerProvider">
      <providers>
        <add name="HtmlAgilityPackSanitizerProvider" type="AjaxControlToolkit.Sanitizer.HtmlAgilityPackSanitizerProvider"></add>
      </providers>
    </sanitizer>
You'll be need ed to add a reference to all three assemblies contained in the folder: SanitizerProviders.dll,and HtmlSanitizationLibrary.dll which can be found in the AjaxControlToolkit source.

Cheers,
Samitha

Tuesday, October 2, 2012

IIS 7.x asp.net 4.0 deployment

If  you have tried to deploy an asp.net 4.0 web application in IIS 7.x you would have come up with few configuration errors. Follow these steps to overcome these errors

 1)  To register .Net in IIS, open up an admin command prompt and navigate to the .NET 4 framework folder (C:\Windows\Microsoft.NET\Framework\v4.{version}). If you're on a 64 bit machine go to the Framework64 folder instead of the Framework folder. Then run aspnet_regiis -i in there  (you will need admin permission on windows 7 to do this)

 2)  Use the "ISAPI and CGI Restrictions" IIS feature to allow your CGI program to run.  You can either add the individual program or simply "Allow unspecified CGI modules".


Cheers
Samitha

Monday, October 1, 2012

TypeScript: JavaScript Application Scaling

  This is a open source scripting language that makes it easier to build large-scale applications that will target HTML5, device applications, cloud applications...etc .I guess this will be the future of Javascript. Read More at  Somasegar's blog

http://blogs.msdn.com/b/somasegar/archive/2012/10/01/typescript-javascript-development-at-application-scale.aspx

Cheers

Samitha