C
C#2y ago
Preda

✅ 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
Mayor McCheese
If the content for each content is static you can just show/hide panels on postback.
Preda
PredaOP2y ago
It is Can you help me please? How sould I declare the Static content
Preda
PredaOP2y ago
Preda
PredaOP2y ago
And how sould I get the Postback event to return a specific thing from the preverious page
Preda
PredaOP2y ago
Preda
PredaOP2y ago
So the buttons down the page have this funciton
Preda
PredaOP2y ago
Mayor McCheese
Are you using webforms or mvc?
Preda
PredaOP2y ago
and should return a form like this
Preda
PredaOP2y ago
Webforms
Preda
PredaOP2y ago
Mayor McCheese
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 😦
Preda
PredaOP2y ago
You spoke a little bit Chineese
Mayor McCheese
How so?
Preda
PredaOP2y ago
.
Mayor McCheese
Maybe I don’t understand your problem then; you want to show/hide content based on a button push.
Preda
PredaOP2y ago
So Based on the button pressed
Preda
PredaOP2y ago
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
Preda
PredaOP2y ago
This is my start page
Preda
PredaOP2y ago
On it I can manage my existing Items and add new ones aswell
Mayor McCheese
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
Preda
PredaOP2y ago
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.
Preda
PredaOP2y ago
or maybe I could do something like this
Mayor McCheese
If you think that will work you should try it then?
Preda
PredaOP2y ago
I don't know how to initialise something like that How to declare the same page as 2 different pages
Mayor McCheese
I mean you have access to query string args
Preda
PredaOP2y ago
Never used
Mayor McCheese
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
Preda
PredaOP2y ago
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
Mayor McCheese
Make them panels
Preda
PredaOP2y ago
Or at least I should get a better view at what they actually mean "Panels"
Mayor McCheese
I don’t think I said that A panel renders as a div or possibly span Who is they?
Mayor McCheese
Right use that
Preda
PredaOP2y ago
The panels I will try
Mayor McCheese
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
Preda
PredaOP2y ago
I am currently learning it in school My teacher said "You are trying to fly without learning to walk"
Mayor McCheese
Put another way; trying to fight against webforms increases the effort to use webforms The panel is the simplest approach
Preda
PredaOP2y ago
I will learn it
Mayor McCheese
Basically in the event handlers you referenced earlier; panel1.Visible = false; panel2.Visible = true; Reversed on the other handler
Preda
PredaOP2y ago
Got it working, thank you a lot!
Accord
Accord2y ago
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.
Want results from more Discord servers?
Add your server