Archive

Posts Tagged ‘AJAX Control Toolkit’

Solve new page flicker in AJAX

October 9, 2009 Leave a comment

Want to stop flickering when going from one page to another in AJAX?

Put the following code in your head section:


<head runat="server">
        <meta http-equiv="Page-Enter" content="BlendTrans(Duration=.05)" />
        <meta http-equiv="Page-Exit" content="BlendTrans(Duration=.05,Translation=0)" />
</head>

For more details about these meta settings, go to http://www.aim-higher.net/meta-transitions.asp.

Categories: AJAX Tags: , , ,

ASP.NET User Control events tamed through Page_PreRenderComplete

October 9, 2009 Leave a comment

Something that has been bothering me for a really long time is now under control thanks to a blog post in the .NET Geek’s Blog entry on Understanding the Page Life Cycle in ASP.NET.  In a nutshell, here is the issue.  I prefer to create user controls that wrap standard .NET controls and then put role enabled and other code into the controls.  That code determines if the control makes it self visible or disabled along with some other nice to haves.

The problem is that when a page first draws and fires off its events, the user control events follow, and if I come into the page wanting a button to be disabled in certian instances, the user controls resolve their states after the page.  So if I have a button in a user control and expose its Enabled property through a get/set variable, I can never make it stick when the page first draws.

In the source code below, I am using the Page_PreRenderComplete event to test for page state and call an appropriate method.  In this case the PrepUIforAdd is called and it disables a number of buttons as well other things.  If I called PrepUIforAdd in the Page_PreRender event, the buttons would never stay disabled.  But calling it in the Page_PreRenderComplete event will result in the outcome I want when the page displays.

		/// <summary>
		/// PreRender is complete
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		protected void Page_PreRenderComplete( object sender, EventArgs e )
		{
			if ( !Page.IsPostBack )
			{
				ucErrorMessage.Clear();

				switch ( this.CurrentPageState )
				{
					case PageState.Add:
						{
							PrepUIforAdd();
							break;
						}
					case PageState.Edit:
						{
							PopulatePersonInfo();
							PopulateLinkedRoles();
							PopulateUnlinkedRoles();
							break;
						}
				}

				this.ManagePersonTabContainer.ActiveTabIndex = 0;
			}
		}

		/// <summary>
		/// Preps UI for adding a person
		/// </summary>
		private void PrepUIforAdd()
		{
			this.txtPersonID.Text = (PersonIDConstant.Everybody.ToInt()).ToString();

			this.txtLastName.Text = string.Empty;
			this.txtFirstName.Text = string.Empty;
			this.txtLogin.Text = string.Empty;
			this.txtPassword.Text = string.Empty;
			this.txtInceptionDate.Text = string.Empty;
			this.txtLastModifiedDate.Text = string.Empty;
			this.txtLastModifiedByPersonName.Text = string.Empty;
			this.ddActive.YesNoID = 1;
			this.ddDeleted.YesNoID = 0;

			lbRolesAvailable.Clear();
			lbRolesSelected.Clear();

			this.bDelete.Enabled = false;
			this.bNew.Enabled = false;
			this.bResetPassword.Enabled = false;
			this.bRoleLink.Enabled = false;
			this.bRoleUnlink.Enabled = false;

			ddEmailType.Clear();
			List<EmailCollection> dt = GetCachedEmailList();
			if ( this.ErrorLevel == Status.Success )
			{
				ddEmailType.DataSource = dt;
				ddEmailType.DataTextField = "EmailTypeName";
				ddEmailType.DataValueField = "EmailTypeID";
				ddEmailType.DataBind();
			}

			this.txtEmail.Text = GetCachedEmailAddress( PersonIDConstant.Everybody.ToInt(), ddEmailType );
		}

Security Exception when using AJAX Control Toolkit on Server 2008

October 2, 2009 Leave a comment

I am using the AJAX Control Toolkit for its tab UI and my compile and link cycles came and went without incident on my Vista development machine.  However when I deployed to our integrated unit test environment on Server 2008, I got the following error when accessing the page with tabs:

System.Security.SecurityException: Request for the permission of type ‘System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’ failed.  Here is a screen shot for reference.

SecurityException

I did a lot of checking and I found articles that involved accessing the AJAX Control Toolkit on a different machine, but that was not my issue.  After publishing via Visual Studio to our server, all dll’s were in their normal folders.

The solution was to change one of the defaults on the application pool for this website.  The value is under the Process Model section in Advanced Settings and is Load User Profile.  By default it is set to false which will emulate IIS6 behavior of not loading the user profile for the application pool identity.  Setting it to true solved the problem.

TheFix

That was it. Make sure you recycle your application pool and restart your web site.

%d bloggers like this: