0

My partner has done a web form user control for me and I add it to my project.

But when add that to a page, the page does not recognize any component from the web form user control. It underlines every single component and say that component is not exist in the current page.

I tried to rename the namespace but it does not get better.

Any suggestion. Thanks so much!

This is the web form user control

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="WebUserControl.ascx.cs" Inherits="GUIFORM_WebUserControl" %>
<style type="text/css">
    .auto-style1 {
        width: 638px;
        height: 161px;
    }
    .auto-style3 {
        width: 30px;
        font-weight: 700;
    }
    .auto-style4 {
        height: 23px;
    }
    .auto-style5 {
        width: 30px;
        height: 23px;
    }
    .auto-style6 {
        height: 23px;
    }
</style>
<table align="center" class="auto-style1">
    <tr>
        <td class="auto-style4">List &#39;s Teacher</td>
        <td class="auto-style5"></td>
        <td class="auto-style6">List &#39;s Student</td>
    </tr>
    <tr>
        <td class="auto-style4">
            <asp:GridView ID="GridView_ListTeacher" runat="server" AutoGenerateColumns="False" Width="283px" OnRowCommand="GridView_ListTeacher_RowCommand">
                <Columns>
                    <asp:BoundField DataField="fullname" HeaderText="FULLNAME" />
                    <asp:TemplateField HeaderText="USERNAME">
                        <ItemTemplate>
                            <asp:Label ID="Label_Username" runat="server" Text='<%# Eval("username") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Current Supervised Students">
                        <ItemTemplate>
                            <asp:LinkButton ID="LinkButton_CPStudent" runat="server"></asp:LinkButton>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="ACTION">
                        <ItemTemplate>
                            <asp:Button ID="Button_Select" runat="server" CommandArgument=<%#Eval("username") %> CommandName="select" Text="Select" />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
        </td>
        <td class="auto-style3"></td>
        <td class="auto-style6">
            <asp:GridView ID="GridView_ListStudent" runat="server" AutoGenerateColumns="False" Height="179px" Width="299px" OnRowCommand="GridView_ListStudent_RowCommand">
                <Columns>
                    <asp:BoundField DataField="fullname" HeaderText="FULLNAME" />
                    <asp:BoundField DataField="username" HeaderText="USERNAME" />
                    <asp:TemplateField HeaderText="ACTION">
                        <ItemTemplate>
                            <asp:Button ID="Button_Select" runat="server" CommandArgument='<%# Eval("username") %>' CommandName="select" Text="Select" />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
        </td>
    </tr>
    <tr>
        <td class="auto-style4" colspan="3" align="center">
            <br />
            <br />
            <asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Italic="False" Font-Overline="False" Font-Size="XX-Large" Font-Strikeout="False" ForeColor="#CC0000" Text="PREVIEW"></asp:Label>
            <br />
            Selected Supervisor:
            <asp:Label ID="Label_SelectedSupervisor" runat="server" Text="NaN" Font-Size="XX-Large"></asp:Label>
            <asp:GridView ID="GridView_Preview" runat="server" AutoGenerateColumns="False" OnRowCommand="GridView_Preview_RowCommand">
                <Columns>
                    <asp:BoundField DataField="fullname" HeaderText="FULLNAME" />
                    <asp:TemplateField HeaderText="USERNAME">
                        <ItemTemplate>
                            <asp:Label ID="Label2" runat="server" Text='<%# Eval("username") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="ACTION">
                        <ItemTemplate>
                            <asp:Button ID="Button_Select" runat="server" CommandArgument='<%# Eval("username") %>' CommandName="select" Text="Remove" />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
            <asp:Label ID="Label_Error" runat="server" ForeColor="#CC0000"></asp:Label>
            <br />
            <asp:Button ID="Button_Submit" runat="server" Text="Submit" OnClientClick="return confirm('Are you sure??')" OnClick="Button_Submit_Click" style="height: 26px" />
            <br />
            <button id="opener">Open Dialog</button>
        </td>
    </tr>
</table>

My friend might save this file in a different folder name with me.

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="WebUserControl.ascx.cs" Inherits="GUIFORM_WebUserControl" %>

I tried to create a new web form user control and it has this line

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="WebUserControl1.ascx.cs" Inherits="CMS.Components.WebUserControl" %>

So I changed the Inherits from "GUIFORM_WebUserControl" to "CMS.Components.WebUserControl"

But still error!

And this is the page I made to embed the web form user control

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="CMS.WebForm1" %>

<%@ Register Src="~/Components/WebUserControl.ascx" TagPrefix="uc1" TagName="WebUserControl" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <uc1:WebUserControl runat="server" id="WebUserControl" />
</asp:Content>
5
  • Did you register the component in the page you are trying to use it in? please include the relevant lines of your code.
    – Las Ten
    Mar 4, 2015 at 12:21
  • Post some code do we can see what you have tried
    – Luthervd
    Mar 4, 2015 at 12:21
  • I have posted my code. please take a look.
    – qangdev
    Mar 4, 2015 at 12:36
  • Your user control src is ~/Components/WebUserControl.ascx but the file might be with name WebUserControl1.ascx. Try changing it.
    – Mahesh
    Mar 4, 2015 at 12:38
  • It is still not working
    – qangdev
    Mar 4, 2015 at 12:49

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.