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();
.net tip
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