I freaking LOVE razor over user controls, but when my page gets complex, I have to revert.
For example, I have a page with two buttons on it. One button for a user to suspend their account, and another for the user to delete their account.
Is there a way with razor to get the server to pick up these post backs? I'm guessing I might be stuck with jquery/webservices or maybe querystring URLS.
Postbacks with Razor?
I freaking LOVE razor over user controls, but when my page gets complex, I have to revert.
For example, I have a page with two buttons on it. One button for a user to suspend their account, and another for the user to delete their account.
Is there a way with razor to get the server to pick up these post backs? I'm guessing I might be stuck with jquery/webservices or maybe querystring URLS.
Yup, use
Cheers,
/Dirk
That's just telling you if there is a post back. I'm trying to do a MVC thing of posting the page to a controller, but I don't think that's possible.
oo, i was looking into what you were saying and it's not isPostBack, sorry I was confused.
I'm not getting my buttons to postback though. I have this <input type="button" value="Suspend Account"/>
When i click on that, the page should postback, correct? Am I missing something?
well, you still need a form and you need
in order to perform a postback
Cheers,
/Dirk
haha, opps! Yah, submit works.
One last question, how do I see the data that was in the fields in the form or tell which button was clicked?
Just as you would with *webforms*, just check Request["nameOfInputField"] and I think your submit button will contain the text you've specified, so
Request["nameOfSubmitButton"] == "Suspend Account"
(Btw, you'll have to add the attribute name in your submit button...)
Cheers,
/Dirk
Sweet! That works! Thansk so much! You just made my life 100x easier!
How do I tell which button submited the form?
i.e. I have
<input type="button" name="btnSuspend" value="Suspend Account"/>
<input type="button" name="btnCancel" value="Cancel Account"/>
Easypeasy to find out, just write out both Request["btnSuspend"] and Request["btnCancel"] and find out what's being posted...
Cheers,
/Dirk
You sir, are a gentleman, a scholar and a badass. Thank you!
is working on a reply...