Monday, August 30, 2010

How Change keyboard layout with Windows 7

Hello Guys on week end I am out of station where I am face a problem with laptop (with Windows 7 operating system) keyboard, some key are different where mention in keyboard.

“Main problem with ‘@’,’”’ Keys is not real place it will on different location”

I am thinking couple of minutes, suddenly I get roughly idea this may be the issue of regional setting.

but i am not aware how check keyboard and layout in Windows 7 because I am using first time, after some time digging on net I got following link which explain how change keyboard layout in windows 7.



When I am check on laptop Keyboards and Language, the default language is selected as United Kingdom that’s why our key board some keys are different,so finally change united states and it working fine for me.


I hope this would help you

Thank you for Reading


Kirti M Darji

Sunday, August 15, 2010

ClientID Mode in ASP.NET 4.0 AND JAVASCRIPT OR JQUERY

Introduction

Hello Guys, I am writing my experience about creating new website and simple functionality about call multiple JavaScript function on same event I am already publish in my previous article. ASP.NET 4.0 new properties ClientIDMode, which can be used to force controls to generate clean Client IDs that don’t follow ASP. Net’s Naming Container ID conventions. Now it is possible to set ClientIDMode Property so developer can set control name in better way but this one create a problem for new developer which are new and switch to asp.net 4.0

Technologies

ASP.NET 4.0, JQuery, JavaScript

Language

C#

Prerequisite

Visual web developer 2010 Express

Implementation

Open visual studio 2010 project and Create new website

we are use JavaScript function for client side validation minimal, use of post back of page or asynchronous post back.

I am creating one JavaScript function like GetTextValue which are use get value from Textbox

I am trying to get value using jquery$(“#textboxname”) and getting null object with master page.

I found something happen due to clientIDMode in asp.net 4.0 let me explain in detail.

If you place the any control inside the content placeholder of a master page, its id will be generated as ctl00$MainContent$txtboxname.

Ctl00 : Random ID generate for Every Master Page You nest like ctl00,ctl01..
MainContent: It Represent ID of master page here is Main Content
Txtboxname: This is the actual ID of Control

you can see depending on master page ID control ID is change if it is nested master page ID is also change. is we change to nested master page case JavaScript return null element so because ID is change that case you have to changes in all place where you write ID to get Element. It is very tedious job.

We can get texbox object using following two way

var txtBoxName = document.getElementById("ctl00$MainContent$txtboxname ");
or
var txtBoxName = document.getElementById("<%=txtboxname.ClientID>");
using jquery
var txtBoxName=$(‘#txtBoxName’)
If we go for first way then it may be issue like nested master page id is change that case second declaration is better.

Second declaration is like mix-up with client side block and server side block and it would be avoided.

In both limitation resolve here in ClientIDMode Property in asp.net 4.0

Asp.net 4.0 new clientIDMode page attribute have following four value we can set.

AutoID

AutoId places one Unique Sequence page id AutoId places one Unique Sequence page id of the controls using ctl00, ctl01 .. .This is the existing behavior in ASP.NET 1.x-3.x where full naming container .it is Default clientIDMode.

Static

This option forces the control’s ClientID to use its ID value directly. No naming container naming at all is applied and you end up with clean client ids:

This option is what most of us want to use, but you have to be clear on that this can potentially cause conflicts with other control on the page. If there are several instances of the same naming container so client ID naming conflict, It’s basically up to you to decide whether this is a problem or not.

Predictable

The key that makes this value a bit confusing is that it relies on the parent NamingContainer’s ClientID to build it’s own client ID value.
For our simple textbox example, if the ClientIDMode property of the parent naming container (Page in this case) is set to “Predictable” you’ll get this:

The most common use however for Predictable will be for DataBound controls, which results in a each data bound item to get a unique ClientID.

Inherit

The final setting is Inherit which is the default for all controls except Page. This means that controls by default inherit the naming container’s ClientIDMode setting. Inherit is slightly different than the AutoId..
AutoId places one Unique Sequence page id of the controls using ctl00, ctl01 .. In case of Inherit mode, it only places the inherited control id for each controls.

within the masterpage, it will give you “MainContent_ txtboxName”. So the only difference between inherit mode and AutoId is that AutoId places the unique PageId like ctl00,ctl01while Inherits doesn’t..

Conclusion

using this article I am trying to ClientIDmode Property which are new features in asp.net 4.0. How all asp.net developer handle the clientIDs batter way using clientIDmode Property.
I hope this would help you
Thank you for Reading

Kirti M Darji

Tuesday, August 10, 2010

Call more then one JavaScript function on same event

Introduction

Today I am working on how call more then one JavaScript function on same event. To achieve this I make some goggling and find solution, which I am sharing with you guys. My Basic requirement is when user enters value in text box the value must be numeric and if text box is not blank then it show save and cancel else hide save cancel button. So this can be achieved by two ways. So here I am representing both way.

Technologies


ASP.NET 4.0, JQuery, JavaScript

Language


C#

Prerequisite

Visual Studio 2005 and Later, my project definition in visual studio 2010.

Implementation

Step-1

Open visual studio 2010 project and Create new website

You can notice one thing there is Scripts file folder are included in project with Jquery virsion 1.4.1 and Default style sheet style.css in visual studio 2010 when we create new website project.
Step-2
Open Default.aspx Source view. Add one Textbox Server control and two Button for Save and cancel..

Default.aspx
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"

    CodeFile="Default.aspx.cs" Inherits="_Default" ClientIDMode="Static" %>










No of item :
 

Above code snipped you notice one thing like ClientIDMode="Static” why I am put that will explain in next article


You can achieve this functionality without call two function on same event like this way call showSaveCancel() function inside intOnly() function like

function intOnly(i) {
 if (i.value.length > 0) 
{ 
i.value = i.value.replace(/[^\d]+/g, '');showSaveCancel(); 
} 
}

Conclusion

Here I am trying to share how call more then one JavaScript function on same event.

Happy Coding

Thank you for Reading

Kirti M Darji