.NET Tip of The Day
Learn one new .NET trick every day
Быстрое пополнение счета телефона      Login or Join

.NET Tips & Tricks Community (ALPHA)

First 1 2 3 4 5  ... Last  RSS

Get name of current controller and action in MVC

Use this.RouteData.Values(“action”) and this.RouteData.Values(“controller”) for getting name of current controller and action in MVC instead of going through the ValueProvider. The RouteData contains information on the request / route (including controller and action), and the value provider contains information used for binding.

 

string controllername = this.ValueProvider.GetValue("controller").RawValue.ToString();
string actionname = this.ValueProvider.GetValue("action").RawValue.ToString();

submitted by Joe K
3/31/2010

.net tip

.net tip

submitted by tiper
2/17/2010

Using Progressbar in a Class

You sometimes need to send a progress report to the user on the status of a particular function. Ex. when inserting records etc.

// FROM YOUR FORM

private void button1_Click(object sender, EventArgs e)

{

       yourclass.updatedb({"One","Two","Three"},this.ProgressBar1);

}

// INSIDE YOUR CLASS

public string updatedb(string[] values,System.Windows.Forms.Progressbar pb)

{

      pb.Maximum = values.Length();

      foreach(string v in values)

             {

                      _insertdb(v); // CALL THE UPATE DB METHOD

                      pb.Value ++; // UPDATE PROGRESSBAR

             }

}

submitted by Paul
11/23/2009

Using Progressbar in a Class

You sometimes need to send a progress report to the user on the status of a particular function. Ex. when inserting records etc.

// FROM YOUR FORM

private void button1_Click(object sender, EventArgs e)

{

       yourclass.updatedb({"One","Two","Three"},this.ProgressBar1);

}

// INSIDE YOUR CLASS

public string updatedb(string[] values,System.Windows.Forms.Progressbar pb)

{

      pb.Maximum = values.Length();

      foreach(string v in values)

             {

                      _insertdb(v); // CALL THE UPATE DB METHOD

                      pb.Value ++; // UPDATE PROGRESSBAR

             }

}

submitted by Paul
11/23/2009
First 1 2 3 4 5  ... Last  RSS
RSS .NET Tip of The Day
Subscribe to receive one tip from the .NET Tips and Tricks Community per day.
Previous Tips of The Day
The best of the .NET Tips & Tricks Community.
.NET Practitioners .NET Tips & Tricks Community
Every .NET practitioner has a trick up in their sleeve. This is the place to share it with other .NET people.
Submit a Tip
Discovered a new trick? Share it with others.
My Tips
Manage tips you authored.