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.