Skip to main content

Dynamic themes

 protected void Page_PreInit(object sender, EventArgs e)
    {
       
        if (Session["theme"] == null)
        {
            Theme = "pink";
           
        }
        else
        {

           Theme = Session["theme"].ToString(); ;
            
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {

    }

    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        Session["theme"] = DropDownList1.SelectedItem.Value;
        Server.Transfer(Request.FilePath);
    }

Comments

Popular posts from this blog

Dot net programming basics

Important things about .net framework
1.Language independent:
* Dot net supports to develop applications in any programming language which are in .net            framework.
2.Common Language Runtime:
* Common Language Runtime(CLR) is a software which is installed along with installation of      visual studio.
* CLR provides a runtime for .net applications.
* It provides garbage collector to free the unused resources.

Sample program
* Open visual studio File menu-> New-> project->Select console application-> Click Ok

           Using System;
           Class mySample
           { 
               Static Void Main()
                 {
                 Console.WriteLine("Wel Come To C#.NET");
                 Console.WriteLine("HAPPY CODING");
                 }
            }

* Press F5 to run.
*Out put  Wel Come To C#.NET
                  HAPPY CODING





Character and word count in c#

private void character(string p)
    {
        string s = p;
        int count = 0;
        try
        {
        char c=Convert.ToChar(TextBox2.Text);

            foreach (char item in s)
            {
                if (item == c)
                {
                    count++;
                }
            }
            Response.Write("no of " + c + " are " + count);
        }
        catch (Exception )
        {
            Response.Write("invalid format given");
        }
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        wordcount(TextBox1.Text);
    }

    private void wordcount(string p)
    {
        int count = 0;
        string s = p;
        string c = TextBox2.Text;
        foreach (Match item in Regex.Matches(s,c,RegexOptions.IgnoreCase))
        {
            count++;
        }

            Response.Write("word" + c + "count is " + count);
        }