Wednesday, November 2, 2011

AJAX Control MaskedEditExtender


AJAX's MaskedEditExtender

Examples of basic properties which we can be used frequently
Enter a Number (format: 9,999,999.99): 



Tip: Type '.' to switch 
 <ajax:MaskedEditExtender runat="server" TargetControlID="txtsatoff" ID="MaskedEditExtender1"

  Mask="9,999,999.99" MessageValidatorTip="false" MaskType="Number" InputDirection="RightToLeft" />

Enter Time (format: 99:99:99): 



Tip: Type 'A' or 'P' to switch AM/PM 
 <ajax:MaskedEditExtender runat="server" TargetControlID="txtsatoff" ID="MaskedEditExtender1"

Mask="99:99:99" MessageValidatorTip="false" MaskType="Time" InputDirection="RightToLeft"
 AcceptAMPM="true" />

Enter Date (format: 99/99/9999): 
  
Tip: The date format is mm/dd/yyyy for this example and a Calendar is also available for date selection 
 <ajax:MaskedEditExtender runat="server" TargetControlID="txtsatoff" ID="MaskedEditExtender1"

 Mask="99/99/99" MessageValidatorTip="false" MaskType="Date" InputDirection="RightToLeft" />

Enter Date and Time (format: 99/99/9999 99:99:99) 
  
 <ajax:MaskedEditExtender runat="server" TargetControlID="txtsatoff" ID="MaskedEditExtender1"

Mask="99/99/9999 99:99:99" MessageValidatorTip="false" MaskType="DateTime" InputDirection="RightToLeft" />


=====================================================
Other Properies of MaskedEditExtender :-
  1. MaskType
  2.  - Type of validation to perform:
    None - No validation
    Number - Number validation
    Date - Date validation
    Time - Time validation
    DateTime - Date and time validation
  3. Mask Characters and Delimiters
    9 - Only a numeric character
    L - Only a letter
    $ - Only a letter or a space
    C - Only a custom character (case sensitive)
    A - Only a letter or a custom character
    N - Only a numeric or custom character
    ? - Any character

    / - Date separator
    : - Time separator
    . - Decimal separator
    , - Thousand separator
    \ - Escape character
    { - Initial delimiter for repetition of masks
    } - Final delimiter for repetition of masks

    Examples:
    9999999 - Seven numeric characters
    99\/99 - Four numeric characters separated in the middle by a "/"
  4. AcceptAMPM - True to display an AM/PM symbol
  5. AcceptNegative - True if the negative sign (-) is allowed
    None - Do not show the negative sign
    Left - Show the negative sign on the left of the mask
    Right - Show the negative sign on the right of the mask
  6. AutoComplete - True to automatically fill in empty mask characters not specified by the user
    MaskType=Number - Empty mask characters will be filled with zeros
    MaskType=Time - Empty mask characters will be filled with the current time
    MaskType=Date - Empty mask characters will be filled with the current date
    MaskType=DateTime - Empty mask characters will be filled with the current date/time
  7. AutoCompleteValue - Default character to use when AutoComplete is enabled
  8. Century - Default century used when a date mask only has two digits for the year
  9. ClearMaskOnLostFocus - True to remove the mask when the TextBox loses focus
  10. ClearTextOnInvalid - True to clear the TextBox when invalid text is entered
  11. ClipboardEnabled- True to allow copy/paste with the clipboard
  12. ClipboardText - Prompt text to use when a clipboard paste is performed
  13. DisplayMoney - Specifies how the currency symbol is displayed
    None - Do not show the currency symbol
    Left - Show the currency symbol on the left of the mask
    Right - Show the currency symbol on the right of the mask
  14. ErrorTooltipCssClass - CSS class for the tooltip message
  15. ErrorTooltipEnabled - True to show a tooltip message when the mouse hovers over an invalid TextBox
  16. Filtered - Valid characters for mask type "C" (case-sensitive)
  17. InputDirection - Text input direction
    LeftToRight - Left to Right
    RightToLeft - Right to left
  18. MessageValidatorTip - Message displayed when editing in TextBox
  19. PromptChararacter - Prompt character for unspecified mask characters
  20. UserDateFormat - Custom date format
  21. UserTimeFormat - Custom time format
  22. OnFocusCssClass - CSS class used when the TextBox receives focus
  23. OnFocusCssNegative - CSS class used when the TextBox gets focus with a negative value
  24. OnBlurCssNegative - CSS class used when the TextBox loses focus with a negative value
  25. OnInvalidCssClass - CSS class used when the text is not valid.
  26. CultureName - Name of culture to use (overrides the default page culture)
  27. CultureAMPMPlaceholder - Culture override
  28. CultureCurrencySymbolPlaceholder - Culture override
  29. CultureDateFormat - Culture override
  30. CultureDatePlaceholder - Culture override
  31. CultureDecimalPlaceholder - Culture override
  32. CultureThousandsPlaceholder - Culture override
  33. CultureTimePlaceholder - Culture override
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Now the Main Problem which we usually face with MaskedEditExtender 

If you are using MaskedEditExtender  with MaskType="Time"
now as we have previously seen that with time type 
MaskType=Time   => Empty mask characters will be filled with the current time

but we require zero(0) in Empty mask characters instead of current time. as normal user will not understand that it will be filled with current time if they are using this control first time then.
For that I have solution
you can use AutoComplete and AutoCompleteValue  properties for this purpose.
SET
AutoComplete="true";
AutoCompleteValue  ="00:00";

 <ajax:MaskedEditExtender runat="server" TargetControlID="txtsatoff" ID="MaskedEditExtender1" Mask="99:99:99" MessageValidatorTip="false" MaskType="Time" InputDirection="RightToLeft"
AcceptAMPM="false" AutoComplete="true" AutoCompleteValue="00:00" />

it will fill Empty mask characters will be filled with the 0.

you can use this stretergy with any MaskType.

This will really help you!!!!!! :)


Tuesday, November 1, 2011

the page has one or more that do not correspond with controls in masterpage

Error:- 


the page has one or more <asp:content> that do not correspond with <asp:ContentPlaceHolder> controls in masterpage



sometimes working on the large project suddenly you will get this error and you will struct there...

B'coz this is a unusual error and Error itself is not explaining the problem. and other thing  you will not get this error while debugging the project or running the project.  your project will run smoothly without any problem.
you will get this error when you will try to open your page in design view from microsoft visual studio.

you will unable to view the design layout of the pages of your projects. its quite uncomfortable to work without checking design layout. so finally you will search and try to solve this problem. 

for coders, it's very difficult to solve the error which is very tough to understand after reading it many times.

for solution you will definitely check the master page and also contentplaceholder. you will also check all the server tag and name of contentplaceholder of the master page and child page. you will fill very complex as all the contentplaceholder have the proper names.

Soooooooo.. here the solutions is.


1) Open your master page file.
2) check for the all the tags. start with <link> <title> <head> <style> <script>

you will surely forget to close one of this tag.

keep in mind that <title> tag should be closed with </title> not with <title / >

still if you are getting the same error then close all the tag same as <title></title>

now check the design layout of the pages. it will load the layout properly from now.


Try this!!!!!!!!!! :)



Wednesday, October 12, 2011

Unable to connect the ASP.NET development server / Error of WebDev.WebServer.EXE

Sometimes when you run the asp.net project then suddenly you will get error like

WebDev.WebServer.EXE Error or 


Unable to connect the ASP.NET development server / Error of WebDev.WebServer.EXE


I had search a lot for this error as i found all the solutions for Unable to connect the ASP.NET development server

but i was not getting because of  WebDev.WebServer.EXE & which was corrupted.
Follow the steps if you find the same error & Enjoy!!!!!!!


whenever we debug our project  (either by pressing ctrl+f5 or only f5) the projetcname.exe which is called by VS2008 is called   WebDev.WebServer.EXE which got corrupted may be n number of reasons

1)      go location C:\Program Files\Common Files\Microsoft Shared\DevServer\9.0
        You will find this file
2)      download WebDev.WebServer.rar file from
        http://www.2shared.com/file/11532086/a7f9858a/WebDevWebServer.html
3)      NOTE :  You will need password for extraction this downloaded .rar file
        Password : optimusprime
4)     Copy the downloaded WebDev.WebServer.EXE  file and replace in http://www.2shared.com/file/11532086/a7f9858a/WebDevWebServer.html


AND THE PROBLEM IS SOLVED NOW!!!!!!!!

Friday, October 7, 2011

Textbox EnableViewstate = false property


What are the effects of Textbox EnableViewstate = false property


EnableViewstate property for textbox,dropdownlist controls doesn't effect anything
even though EnableViewstate is false or true.
if this is the case why Enableviewstate property exists for those controls?
No, not exactly. ViewState save any programmatic changes of textbox. For instance, you set textbox value


this.TextBox1.Text = "somevalue"

in a button click event. After postback this value will be saved in Save ViewState event method. When other submit or postback happend. ASP.NET will check the ViewState to load "somevalue" to textbox text property again. which this value is set in pervious visit(click the button).
More information. please check the paragraph #The Role of View State of Understanding ViewState article:

Thursday, October 6, 2011

Missing partial modifier on declaration of type; another partial declaration of this type exists

ERROR:-
I had below codes, but prompt me an error...

namespace FindUserGroup
{
public class ViewUser : System.Web.UI.WebControls.WebParts.WebPart
{
public ViewUser() { }
protected TextBox txtName;
protected Button btnSearch;
protected GridView gvFindGroup;

void btnSearch_Click(object sender, EventArgs e)
{............

By default, C# will give me:

"public partial class ViewUser : System.Web.UI.Page",
when i change it to:  "public class ViewUser : System.Web.UI.WebControls.WebParts.WebPart", it prompts me an error of "Missing partial modifier on declaration of type........, another partial declaration of this type exists".

SOLUTIONS:-
Do you have Usercontrols/Web Pages(C#) migrated from previous version of VS (2003 to 2005)?
It does creates ".aspx.designer.cs" files for you... and the classes are declared in that file too... with
"public partial class"..

In my case I have to add (or make sure) the partial word  in between public and class on all those pages/user conrtols...

I hope it will help somebody who is having the similar issues...