Tuesday, June 10, 2008

Few more tips..

To trim or remove trailing zeros from a decimal

string trimDec = "12.0000";

trimDec.TrimEnd("0.".ToCharArray()) + "%"

Displays 12%

Tip # 2
if you pop open up a window when a button is clicked, the user doesnt close the pop up and clicks on the button again, you may want to close the pop up and re open again... use the code below..

// To see if the window was present and close the pop up
ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(string), "closeit", "MyExample.close();", true);

ScriptManager.RegisterStartupScript(this.UpdatePanel2, typeof(string),
"alertScript",
"MyExample = window.open('NewPage.aspx','" + this.ddlvalue.SelectedValue + "','resizable = 1,status=0,toolbar=0,location=0,scrollbars=1,width=800px'); ", true);



Tip #3
To access a public method from a Master page in a child page that is using the master page...

Class Name objName = (Cast it as the class name)Page.Master;

MasterPage ParentMasterPage = (MasterPage)Page.Master;

No comments: