Results 1 to 2 of 2

Thread: Custom UserControl and Method calls

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2003
    Posts
    90

    Custom UserControl and Method calls

    Hello,

    I have a custom control that is the header for all of my web pages. I now have a need to change the logo at the top of the control based on a database value. What I did was to put a call to my method in the .ascx page here is what it looks like

    <img border="0" src='<%# GetClientLogo() %>' .......

    Here is the GetClientLogo in the codebehind .vb file

    Function GetClientLogo() As String

    if bIsLogged then
    return "../Images/" & sLogo
    Else
    return "../Images/cleardot.gif"
    endif
    end function


    When this runs I do not get any error, but it does not work. I have put it into debug and I can catch the Page_Load sub fine, but can not catch anything in the GetClientLogo. Seems as if the code is never executed. Any help would be great!

    Thanks

  2. #2
    Lively Member neodatatype's Avatar
    Join Date
    Aug 2002
    Location
    Italy
    Posts
    103

    Re: Custom UserControl and Method calls


    I have a custom control that is the header for all of my web pages. I now have a need to change the logo at the top of the control based on a database value. What I did was to put a call to my method in the .ascx page here is what it looks like

    <img border="0" src='<%# GetClientLogo() %>' .......
    You cannot use ASP.NET as the old ASP!
    ASP.NET does not support html and asp misture: it has a code and a html section well separated.

    To do what you want you should create a asp.net webcontrol (in C# has .ascx extension, I dont' know in VB.NET) with your *visual* code (just like a windows control).

    After you can do this
    - At the top of your pages put something like

    Code:
    <%@ Register TagPrefix="myAspNamespace" TagName="myControlClass" Src="/shared/myControl.ascx" %>
    - In the html body, where you want put the control:

    Code:
    <myAspNamespace:myControlClass id="myControl1" runat="server"></myAspNamespace:myControlClass>
    It will do something similar to the old ASP #Include

    Bye!
    > NeoDataType.net <

    Try my Free .Net Reporting Tool!

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