Friday, 28 March 2014

how to count number of online users in asp.net

Simple two steps:

1.Add this code in Global.asax


void Application_Start(Object Sender, EventArgs E)
        {
            Application["CurrentUsers"] = 0;
        }
        void Session_OnStart(object Sender, EventArgs E)
        {
            Application.Lock();
            Application["CurrentUsers"] = System.Convert.ToInt32(Application["CurrentUsers"]) + 1;
            Application.UnLock();
        }
        void Session_OnEnd(object Sender, EventArgs E)
        {
            Application.Lock();
            Application["CurrentUsers"] = System.Convert.ToInt32(Application["CurrentUsers"]) - 1;
            Application.UnLock();
        }

2.In Aspx Page

<%=Application["CurrentUsers"].ToString()%>

In web.config timeout will be make 10, by default 20

Friday, 21 March 2014

hex code for checkbox and apply to css

HEX Code for check box is :
                         Checked :2610,
                    Un Checked :2611.

In Css
.checked:before
{
    content:"\2611";
    }
in Aspx page or html page or View

<a href="#" class="checked"></a>

Tuesday, 11 March 2014

dynamic menu li selected item highlighted using jquery or javascript

Use the following steps for archiving li selected item highlited.

Loop Code :1

@foreach (class obj in list)
        {
            <ul>
                <li  class="@obj.strName" style="font-weight:bold;" ><a href="#"  style="text-decoration:none;" >
 </a></li>
            </ul>
        }

Css: 2
.li
    {      
        background-color:#bb0d2d !important;
        color: white !important;      
    }

JQuery: 3
$('li').click(function () {
        $(this).addClass('li');
    });

Wednesday, 5 March 2014

default button in html using jquery

use this steps:
Html or aspx or View
create textbox and button in the page and assign id,

Then,

JQUERY

$("#textboxID").keyup(function (event) {
        if (event.keyCode == 13) {
            $("#buttonID").click();
        }
    });

Thursday, 27 February 2014

html.actionlink target _blank

@Html.ActionLink("string name", "Actionname", "Controllername", "", new { target = "_blank" })

this code working fine.

Wednesday, 19 February 2014

read resource file in asp.net

Step:1

Add resource file in your application

step:2

create a page for input text and output result label.

step:3

in code behind add this line

System.Resources.ResourceManager rm = new System.Resources.ResourceManager("Yourresourcefilenamespace.resourcefilename(without extention.resx)", this.GetType().Assembly);
        It cerates reslult set      
                var entry =
                    rm.GetResourceSet(System.Threading.Thread.CurrentThread.CurrentCulture, true, true)
                      .OfType<System.Collections.DictionaryEntry>().Where(e => e.Key.ToString() == "input text").Select(v=>v.Value);
      for single row
 var entry =
                    rm.GetResourceSet(System.Threading.Thread.CurrentThread.CurrentCulture, true, true)
                      .OfType<System.Collections.DictionaryEntry>().FirstOrDefault(e => e.Key.ToString() == "your text");
                     

                var key = entry.Value.ToString();

Monday, 10 February 2014

httpcontext.current namespace for asp.net mvc

simple change in this
instead of this line 

HttpContext context = HttpContext.Current;

change to
HttpContext context = System.Web.HttpContext.Current;

dont forgot to add using system.web;   namespace in the page in mvc Application.