.net

By steve, 27 February, 2012

To get a pop-up to appear in .NET from the code behind, you can do the following:

ScriptManager.RegisterStartupScript(this, this.GetType(), "alertName", string.Format("javascript:alert('Message to display with argument {0}')", argument1), true);

Tags

By steve, 17 June, 2011

While writing my first web service in .NET I came across the following error:

Cannot serialize member System.ComponentModel.Component.Site of type System.ComponentModel.ISite because it is an interface.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Tags

By steve, 8 June, 2011

I am having a problem where certain dynamic controls are not having their events triggered. I can re-create the problem by getting my code to re-create the controls in the PreRender event as follows:

protected void Page_PreRenderobject sender, EventArgs e)
{
GenControls();
}

protected void Page_Load(object sender, EventArgs e)
{
GenControls();
}

Tags

By steve, 8 June, 2011

To make a web page return to the same position after a postback, 2 things are required. First, the following must be added to the web.config file:

Second, add the following into the Page_Load() function for the page:

protected void Page_Load(object sender, System.EventArgs e)
{
Page.MaintainScrollPositionOnPostBack = true;
}

Tags