Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accessing Button Click from Master page on Content page 1

Status
Not open for further replies.

Halliarse

IS-IT--Management
Jan 8, 2007
213
GB
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
 
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.
 
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
 
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.
 
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
 
If you have multiple forms and are writing repetitive code, then you should be using master pages.
 
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
 
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.
 
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
 
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top