Thursday, August 9, 2012

Auto Generate Serial Number in GridView

To auto generate serial number in Gridview, which we can use only for display purpose and has nothing to do with database and data related operations.

  • Add Following Column in Grid View at first position

       
       <%# ((GridViewRow)Container).RowIndex + 1%>
   
 

Above code will simply autogenerate serial number in Gridview
Submit this story to DotNetKicks

Read more...

Wednesday, August 1, 2012

Textbox with background image using CSS

We can use CSS To make stylish textboxes like rounded corner textbox or textbox with some image inside. Rounded corner text box is like following image.


To make rounded corner textbox we use following logic. We will put textbox in some wrapper layer i.e. div tag and apply style to wrapper layer.
Now style applied to wrapper div tag is as follows
.tt-wrapper
 {
 background-image:url('images/user_box.png');
 margin:0;
 width:255px;
 height:35px; 
  }
In above style user_box.png is a background image (check following image.)


 Then we apply style to fit the textbox with in wrapper div class.
.tt{
 width:240px;
 height:25px;
 margin:5px 0 0 8px;
 border:none;
 background:none;
 }
And we are done with Textbox with rounded corner. To display some image inside textbox we simply need to add background image in the class applied to textbox
Submit this story to DotNetKicks

Read more...

Install CSI files BlackBerry

I am using PhoneGap.com for BlackBerry development, after developing web app I came across a situation where I had to register my code signing key using  SignatureTool.jar, I used following line of code in Command prompt to register my key and password pair. C:\BBWP\bin>SignatureTool.jar client-RBB-YOURCSICODE.csi c:\BBWP\bin>SignatureTool.jar client-RCR-  YOURCSICODE.csi c:\BBWP\bin>SignatureTool.jar client-RRT-  YOURCSICODE.csi If you don't have a private key installed you need to create one. And use the pin number which you used during the registration process.
Submit this story to DotNetKicks

Read more...

Javascript Find Arguments Passed to a Function

While working on Javascript optimization we can always use some functions having variable number of arguments.
E.g. if we come across a situation where we have to use one function to toggle visibility of the objects, but depending on clients input number of objects which needs to hide/show varies. In this case we can write a function as below where number of parameters can any variable.
//Assumption 0th parameter is boolean 

 function toggle() {
        var args = toggle.arguments
        for (v = 1; v < args.length; v++) {
            obj = window.document.getElementById(args[v]);
            if (args[0]) obj.style.display = "";
            else obj.style.display = "none";
        }
    }
We can use this type of functions to minimize size of javascript before optimizing it.
Submit this story to DotNetKicks

Read more...

Logout User In Asp.net Membership

While developing usermanagement based web application using Membership provider, many times we come across some trivial issues or queries as follows
  • formsauthentication.signout not working
  • Using formsauthentication.signout
  • logout user programmatically
  • Check user date subscription and log out if user is not valid.
  • programmatically logout in asp net
  • Logout user in asp.net Membership
Solution for all above queries is as follows
FormsAuthentication.SignOut();
  Session.Abandon();

 // clear authentication cookie
 HttpCookie frmcookie = new HttpCookie(FormsAuthentication.FormsCookieName, "");
 frmcookie.Expires = DateTime.Now.AddYears(-1);
 Response.Cookies.Add(frmcookie);

 // clear session cookie if we use any
 HttpCookie sessioncookie = new HttpCookie("ASP.NET_SessionId", "");
 sessioncookie.Expires = DateTime.Now.AddYears(-1);
 Response.Cookies.Add(sessioncookie);

 FormsAuthentication.RedirectToLoginPage("v=SubscriptionExpired");
Above code signout the user, remove all the Cookies set. Forms Authentication.RedirectToLoginPage uses settings in web.config file. We can pass Querystring to the function so that we can show proper Messages.
Submit this story to DotNetKicks

Read more...

Display rupee symbol website

To display Rupee Symbol to website use following code.
Ruppee Symbol

  1. Add a stylesheet link in the head section of your webpage:


  • Add the following code enclosing your "Rs."
    Rs. 1000
    
  • OR Just include the following javascript and it will update all the "Rs" / "Rs." for you
    
    
    This is how we can display indian rupee symbol in website/blog. If Unicode is supported then we can use rupee symbol positioned at U+20B9.
    Submit this story to DotNetKicks

    Read more...