dcsimg
Results 1 to 8 of 8

Thread: [RESOLVED] How to use the Anchor Tag in conjunction with Div Button?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    4,832

    Resolved [RESOLVED] How to use the Anchor Tag in conjunction with Div Button?

    I've created a menu in an ASP.Net page using the DIV element. There are 8 menu buttons. Each one, when clicked on, should load a Panel with Images that are located in specific directories. Each button should point to a specific directory. What is the best way to reference these directories. Should I use Javascript or C# code-behind or both? I was unable to find a good code example using the Anchor Tag referencing directories.

    Thanks,
    Blake

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    99,788

    Re: How to use the Anchor Tag in conjunction with Div Button?

    Is this Web Forms?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    4,832

    Re: How to use the Anchor Tag in conjunction with Div Button?

    No...it's an ASPX page.
    Blake

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    4,832

    Re: How to use the Anchor Tag in conjunction with Div Button?

    Actually, what I'm trying to do is link these Anchor elements with C# via the "onclick" event within the DIV. See below.

    Code:
                <div class="ButtonCategories">
                    <a id="catgButton1" onclick="CatgButton_Click(id)"><literal>Report Files 1</literal></a>
                </div>
    
                <div class="ButtonCategories">
                    <a id="catgButton2" onclick="CatgButton_Click(id)"><literal>Report Files 2</literal></a>
                </div>
    
                <div class="ButtonCategories">
                    <a id="catgButton3" onclick="CatgButton_Click(id)"><literal>Report Files 3</literal></a>
                </div>
                 .
                 .
                 .
    The "CatgButton_Click" event resides in the C# code-behind. I'm just not sure how to trigger it when the above buttons are clicked.

    Thanks,
    Blake

  5. #5
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    99,788

    Re: How to use the Anchor Tag in conjunction with Div Button?

    ASPX pages are Web Forms. If you create an ASP.NET application then you have a choice of technologies. The original ASP.NET was Web Forms. They have since also introduced MVC, Web Pages and Web API. Web Forms uses ASPX pages for the HTML generation and CS files for the codebehind.

    I have barely used Web Forms at all and not for a while but I think that anything you put in that 'onclick' attribute of the tag will be interpreted as JavaScript. If you wanted to create an ASP.NET server control with an event handler in the code-behind then you would need to actually add a server control, probably via the designer, rather than just writing standard HTML. If you want to invoke code-behind from JavaScript then you would need to actually submit a form or build your own request and submit that, e.g. via jQuery.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    4,832

    Re: How to use the Anchor Tag in conjunction with Div Button?

    I did do the latter of what you said, invoked VB.Net code-behind using Javascript. It's been quite a while ago and I don't have any sample code. I'll keep searching until I find this. It's been a while since I've done web development. Thanks for your input jmc!
    Blake

  7. #7
    Superbly Moderated NeedSomeAnswers's Avatar
    Join Date
    Jun 2002
    Location
    Manchester uk
    Posts
    2,461

    Re: How to use the Anchor Tag in conjunction with Div Button?

    If you want to be able to access a Web component server side then you need to give it the tag RunAt="Server"

    You can certainly do this with a Div and probably a hyperlink to, then you will be able to have a serverside OnClick method, normally it will create the Click method for you, as you write the OnClick method it will ask you to Tab to create the method.
    Please Mark your Thread "Resolved", if the query is solved & Rate those who have helped you



  8. #8

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    4,832

    Re: How to use the Anchor Tag in conjunction with Div Button?

    That's right...I remember that now! Thank you NeedSomeAnswers...
    Blake

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width