CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2007
    Posts
    210

    ascx web control not appearing in aspx file

    can anyone please tell me what i'm doing wrong? this is the first time i;ve tried using these controls. It compiles ok and when i run it the other ascx file is have added appears but not the supplier_list.ascx. I have the following aspx file;

    Code:
    <%@ Page Language="VB" AutoEventWireup="True" Theme="Theme" Debug="true" %>
    <%@ Register TagPrefix="Side_Frame" TagName="SupplierList" Src="supplier_list/supplier_list.ascx" %>
    <%@ Register TagPrefix="Side_Frame" TagName="SearchPanel" Src="search_panel/search.ascx" %>
    	
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <head id="Head1" runat="server">
    </head>
    
    <body>
    
    <form runat=server>
    <asp:Table Width="150px" runat="server">
    	<asp:TableRow>
    		<asp:TableCell>
    	        	HEREE
    			<Side_Frame:SupplierList id="supplier_list" runat="server" />
    		</asp:TableCell>
    	</asp:TableRow>
    	<asp:TableRow>
    		<asp:TableCell>
    			<Side_Frame:SearchPanel id="search" runat="server" />
    		</asp:TableCell>
    	</asp:TableRow>
    </asp:Table>
    </form>
    
    </body>
    </html>
    the proble is the supplier_list.ascx is not appearing. the ascx file contains

    Code:
    <%@ Control Language="VB" AutoEventWireup="false" CodeFile="supplier_list.ascx.vb" Inherits="supplier_list" %>
      
    <asp:DataGrid id="MyDataGrid" AutoGenerateColumns="false" runat="server">
      	 <HeaderStyle CssClass="DataGridHeaderStyle"></HeaderStyle>
         <Columns>
                <asp:HyperLinkColumn
    		 ItemStyle-CssClass ="ColumnItem"
                     HeaderText="Manufacturers"
                     DataNavigateUrlField="supplierID"
                     DataNavigateUrlFormatString="detailspage.aspx?id={0}"
                     DataTextField="name"
                     DataTextFormatString="{0:c}"
                     Target="_blank">
    			<ItemStyle CssClass="ColumnItem"></ItemStyle>
    	    </asp:HyperLinkColumn>
        </Columns>
    </asp:DataGrid>
    and the .vb file for this is

    Code:
    Imports System.Data
    Imports System.Data.Odbc
    Imports System.Data.SqlClient
    
    Partial Class supplier_list
        Inherits UserControl
    
        Protected Shared Function getConnectionString() As String
            'Pass the connectionstring in the appsettings of the web.config file
            Return ConfigurationManager.AppSettings("Connectionweb")
        End Function
    
        Function CreateDataSource() As DataSet
    
            Dim oQRY As String = "SELECT supplierID, name FROM suppliers"
            Dim oDataAdapter As ODBCDataAdapter
            Dim oDataSet As DataSet = New DataSet()
    
            oDataAdapter = New ODBCDataAdapter(oQRY, getConnectionString())
            oDataAdapter.Fill(oDataSet)
     
            Return oDataSet
    
        End Function
    
        Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
    
            MyDataGrid.DataSource = CreateDataSource()
            MyDataGrid.DataBind()
    
        End Sub
    
    End Class

    many thanks,

    Matt.

  2. #2
    Join Date
    Mar 2007
    Posts
    210

    Re: ascx web control not appearing in aspx file

    Hi Guys,

    sorted the problem it was here AutoEventWireup="false" all i needed to do was set this to true, this was stopping the page_load from firing automatically on the load.

    thanks,

    Matt.

  3. #3
    Join Date
    Jan 2008
    Location
    Atlanta, Georgia - United States
    Posts
    75

    Re: ascx web control not appearing in aspx file

    Gotta love those one liners...I've spent hours trying to debug tens of thousands lines of code and in the end, it's always something stupid like that...something I purposely set for debugging.
    Consider rating any helpful responses. I do not provide line level response for C#. Get your C# help in the C# forum!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured