✅ ASP.NET Web Server
I am trying to have 2 buttons on a page (the buttons are standing to redirect to an item creation page) and depending on the button pressed your content should differ.
for my example I'll leave screenshots. So when the button is pressed on the "details.aspx" page I want to show a specific form based on the button, in the "creation.aspx" page.
Note: I don't want to use 2 diffrent aspx pages
43 Replies
If the content for each content is static you can just show/hide panels on postback.
It is
Can you help me please?
How sould I declare the Static content
And how sould I get the Postback event to return a specific thing from the preverious page
So the buttons down the page
have this funciton
Are you using webforms or mvc?
and should return a form like this
Webforms
So I’m assuming the static content is hardcoded on the page in a panel control with a runat server; and that on postback the event handle for the button press can show/hide the panel controls
But my webforms experience is old there may be newer paradigms.
I’m also on an airplane with spotty internet 😦
You spoke a little bit Chineese
How so?
.
Maybe I don’t understand your problem then; you want to show/hide content based on a button push.
So
Based on the button pressed
I should see a different output on my 2nd page
Not what I am looking for, I think
Let me get it in more steps and clear
Maybe I can get you a better idea
This is my start page
On it I can manage my existing Items and add new ones aswell
I’m on my phone on a plane; sorry I can’t see that image well
I still don’t understand how two panels and setting visibility doesn’t solve your problem.
So again; I probably don’t understand your problem; I’ve not used webforms since 2005ish
As you can see 2 buttons on the bottom
1. Nieuwe plaats (which stand for new place so a new item that is composit of the Building)
2. Nieuwe gebouw (which stand for a new building)
Both buttons should redirect me to New.aspx
And depending on the button I should see a different from to input data
I see.
or maybe I could do something like this
If you think that will work you should try it then?
I don't know how to initialise something like that
How to declare the same page as 2 different pages
I mean you have access to query string args
Never used
On the page load
So on the page load you’d … show or hide the panels based on the query string args id being 1 or 2
So you are telling me, I can do query string args from page abc.aspx and put them in xyz.aspx using calling it in the Page_Load()?
I don't think they are panels
Make them panels
Or at least I should get a better view at what they actually mean "Panels"
I don’t think I said that
A panel renders as a div or possibly span
Who is they?
https://learn.microsoft.com/en-us/dotnet/api/system.web.ui.webcontrols.panel?view=netframework-4.8.1
Panel Class (System.Web.UI.WebControls)
Represents a control that acts as a container for other controls.
Right use that
The panels
I will try
And you don’t need querystring if content is on the same page since webforms gives you the postback abstraction
Just let webforms do it’s job
Webforms is a heavyweight with useful event style abstractions that simplify web interactions. If you aren’t using it to simplify your backend interactions don’t use webforms
I am currently learning it in school
My teacher said "You are trying to fly without learning to walk"
Put another way; trying to fight against webforms increases the effort to use webforms
The panel is the simplest approach
I will learn it
Basically in the event handlers you referenced earlier; panel1.Visible = false;
panel2.Visible = true;
Reversed on the other handler
Got it working, thank you a lot!
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.