INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Accessing Button Click from Master page on Content page

Accessing Button Click from Master page on Content page

(OP)
ASP 4.0 VS2012 VB

Hi

I have created a master page which includes buttons that I want to programmatically change values for and based on those values, when the button is clicked, perform various tasks.

The buttons are all ionitially sent to visible = false and the text value = "" and when I run my default.aspx my master page loads perfectly with the buttons in the right place, visible and with the text as defined in my code.

So far so good, however I need to obviously action the button, from the content page and assume that I need an EventHandler for the _Click function, and this is where I run into trouble as I cannot work out how to define this within the default page.

Any ideas to point me in the right way please?

Many thanks

Steve

RE: Accessing Button Click from Master page on Content page

What have you tried so far? Any code to post?
Why do the buttons need to be on the master page? If their actions change based on content, then why not put them on the content pages themselves?

Not sure what you are trying to accomplish. Maybe if you explain better, a better solution can be found.

RE: Accessing Button Click from Master page on Content page

(OP)
Hi again JBenson001

I have put the buttons on a master page as after lots of research decided that that was the best approach and one that limited the amount of duplicated form building as I do have a lot of forms.

My original plan was to do everything on each form!

You wil be familiar with my master page as you advised on it previously....I have a navigation bar which has a set of 5 buttons, all set to visible = false without any text value. Dependant on the Login credentials I set the navigaton bar, setting text values to the buttons. On the left hand side I have a set of 10n buttons, each all set as per the navigation bar buttons. What I'm trying to acheive is when the navigation bar is clicked, the buttons on the left are created. The user then selects an option and the contect screen is then displayed.

What I am trying to acheive is a butAdd_Click(sender As Object, e As EventArgs) Handles butAdd.Click scenario but using the buttons on the Master.

If this is not possible then I'll just revert to my original plan and do everything at content page level.

What are your thoughts?

Thanks

Steve

RE: Accessing Button Click from Master page on Content page

If I am understating correctly, it seems like you are building the buttons based on the main nav bar selection?
If so, it sounds like you want to add the buttons dynamically to the master page. This can be done, but the coding can get a bit hairy and confusing.
You have to add a button to the page, or another control on the page, then set up the event handler in code, there will not be a "Handles butAdd.Click"

OR

If the number of buttons is consistent, like, 5 for the first option, 4, for the next, 7 for the next etc. then you can just add all of your buttons to the master page and set up the click events.
Then when the user chooses an option in the main nave, just show/hide the detail buttons as necessary. This in my opinion would be the easiest code to write and maintain.

RE: Accessing Button Click from Master page on Content page

(OP)
Hi JBenson001

I've reverted back to everything on each page and I can code that easilty so I won't use the Master page option!

Thanks

Steve

RE: Accessing Button Click from Master page on Content page

If you have multiple forms and are writing repetitive code, then you should be using master pages.

RE: Accessing Button Click from Master page on Content page

(OP)
Apologies, we posted at exactly the same time!

My chosen choice was your 'OR' option and that was what I was trying to explain, if somewhat ineloquently!

How do I go about showing / hiding the buttons as required then because that then assumes I monitor I click....is this monitored on the Master page itself then?

Thanks

Steve

RE: Accessing Button Click from Master page on Content page

You said you will have a set amount of buttons in the main header. Put code in each click event (on the master page) of each button to show/hide the other buttons.

RE: Accessing Button Click from Master page on Content page

(OP)
Works perfectly!

The only issue I have there is I now have a row of vertical buttons (menu items), how do I get a gap inbetween them? I tried using <li /> which works but the gap is far too big!

Thanks for your ongoing support

Steve

RE: Accessing Button Click from Master page on Content page

This is where you will have to play around with CSS, a good learning exercise.
You can place each in a div(of a certain width) and float them? Have them in an <li> and set the width on them.

There are many ways, just depends on what you want. And not really any wrong or right way.

You can always find a site that has a layout that you would like to model yours after, and take a look at the source of the page. You may not see the CSS but you can get an idea from it.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close