• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 432
  • Last Modified:

asp.net c# wizard and usercontrol not working

check attached code. I just can not find why Response.Write(principalname.ToString()); has nothing to be shown.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<%@ Register src="PrincipalControl.ascx" tagname="PrincipalControl" tagprefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <form id="form1" runat="server">
        <asp:Wizard ID="Wizard1" runat="server" Height="269px" Width="474px" 
            ActiveStepIndex="1" onfinishbuttonclick="Wizard1_NextButtonClick">
                <asp:WizardStep runat="server" title="Step 1">
                <asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
                <asp:WizardStep runat="server" title="Step 2">
                <asp:PlaceHolder ID="PlaceHolder2" runat="server"></asp:PlaceHolder>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Default2 : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)
        PrincipalControl newprincipal = (PrincipalControl)LoadControl("PrincipalControl.ascx");
    protected void Wizard1_NextButtonClick(object sender, WizardNavigationEventArgs e)
       if (Wizard1.WizardSteps[e.NextStepIndex].StepType == WizardStepType.Finish)
            for (int i = 0; i < PlaceHolder1.Controls.Count; i++)
                PrincipalControl newprincipalinfo = (PrincipalControl)PlaceHolder1.Controls[i];
                string principalname = newprincipalinfo.principalname;

Open in new window

1 Solution
I doubt the value for principalname property is not set in your usercontrol...
Can you share the PrincipalControl UC control code?
Set breakpoints and see if the property value is getting set....before you are trying to access it.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now