Tuesday, July 31, 2012

How to Insert page break during printing


This code is helpful when you want insert page breaks between the page. You have to divide your content in divs.

<script language="javascript" type="text/javascript">
    function PrintPageBreakAfter( ){
              divs = document.getElementsByTagName(arguments[0]); 
              for (var i=0; i < divs.length-1; i++ ) { 
                     div = divs[i];
                     if(div.id!=''){
                            div.style.pageBreakAfter = (arguments[1]) ? "always":"";
                      }
           }
window.print(); 

}
    </script>


<body onload="JavaScript:togglePageBreakAfter('DIV', true, true);" topmargin="0">


<div id="div1">
   Content
</div>


<div id="div2">
    Content
</div>
free web site traffic and promotion

Wednesday, July 25, 2012

Ajaxtootlkit Color Picker: _colorRegex undefined

I was using the colorpicker as per ajaxtoolkit site directives in my project.

but still I was getting one javascript error called _colorRegex undefined.

After searching on google I found below javascript code. Put this code after your ColorPickerExtender control

  <asp:ColorPickerExtender ID="buttonCPE" runat="server" TargetControlID="txtColorCode" PopupButtonID="Image1" SampleControlID="Sample1" SelectedColor="" />

<script type="text/javascript">
//This code must be placed below the ScriptManager, otherwise the "Sys" cannot be used because it is undefined.
Sys.Application.add_init(function() {
// Store the color validation Regex in a "static" object off of
// AjaxControlToolkit.ColorPickerBehavior. If this _colorRegex object hasn't been
// created yet, initialize it for the first time.
if (!Sys.Extended.UI.ColorPickerBehavior._colorRegex) {
Sys.Extended.UI.ColorPickerBehavior._colorRegex = new RegExp('^[A-Fa-f0-9]{6}$');
}
});
</script>

Hope this would be helpful to you.
free web site traffic and promotion

How to use recaptcha in ASP.NET


Hi Friends,

Today I will let you know steps to use recaptcha in ASP.NET Code.

1.) Generate a public and private key from recaptcha.net.
2.) Download recaptcha.dll from the net.
3.) Add this dll as reference in your project.
4.) <%@ Register TagPrefix="recaptcha" Namespace="Recaptcha" Assembly="Recaptcha" %> add this line in your aspx page.
2.) <recaptcha:RecaptchaControl ID="recaptcha1" runat="server" PublicKey="your public key" PrivateKey="your private key" Theme="clean" /> add this control inside the <form> tag.
3.) recaptcha provide bydefault 4 themes e.g red, blackglass, clean and white. You can use any of them.
4.) To check its working fine or not. Use below code in your cs file.

recaptcha1.Validate();
if (recaptcha1.IsValid)
{
// Work here after satisfaction of captcha.
}

free web site traffic and promotion