Google Mail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
MVC
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  17 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Follow-up To:
Add Cc | Add Follow-up to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers that you hear
 
Thom Shannon  
View profile   Translate to Translated (View Original)
 More options 14 Sep, 11:25
From: Thom Shannon <t...@glow-internet.com>
Date: Mon, 14 Sep 2009 11:25:08 +0100
Local: Mon 14 Sep 2009 11:25
Subject: MVC

anyone else using it much?

The theory sounds great, but when you actually get into it's quite hard
to work how to fit an application into it. Examples and docs seem to be
really lacking and most of the code you find is out of date. I'm trying
to figure out how to get some search results to update from a couple of
different search types at the top of the page, eg.
Search by code |___| <Go> or Search by Department |_______| <Go>

So I have two forms, I thought they'd both submit back to the same Index
action and just pass a param of either the code or department name, but
there's no way to do that! You can't have two actions with the same name
let alone param data type. I can have one form with two params on the
action that match up based on the name but then I don't know which
button they clicked, or what box they hit enter in.

Any ideas?

--
* Want to become an expert Digital Marketer?
www.glow-internet.com/bootcamp <http://www.glow-internet.com/bootcamp>

Glow New Media
t: 0151 707 9770
m: 07730 987 574
www.glow-internet.com

Suite 712 Gostins Building
32-36 Hanover Street
Liverpool
L1 4LN

Follow me at http://twitter.com/tshannon

Map: http://tinyurl.com/2f5nxd

Terms & Conditions Apply: http://www.glow-internet.com/home/terms.aspx


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Donovan Hide  
View profile   Translate to Translated (View Original)
 More options 14 Sep, 11:32
From: Donovan Hide <donovanh...@gmail.com>
Date: Mon, 14 Sep 2009 11:32:54 +0100
Local: Mon 14 Sep 2009 11:32
Subject: Re: [luodn] MVC
Hi Thom,

you've got a few options:

- Build a url which describes the form submit and redirect through
routing to the appropriate action, eg:

/search/code/ goes to SearchController with action Code

/search/department/ goes to SearchController with action Department

- Add a form field which describes the search type and do a switch on
the action parameter, eg:

all POST's go through /search/ to SearchController with action Search

form fields:

Term = ExampleCode0023
Type = Code

and

Term = BiologyDepartment
Type = Department

It's a bit different from the event model of ASP.NET, but once you get
the hang of it you don't really have any limits to what you can do.
And it makes it so much easier to embed a Google Search form on your
page that works!!!

Cheers,
Donny.

2009/9/14 Thom Shannon <t...@glow-internet.com>:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Derek Fowler  
View profile   Translate to Translated (View Original)
 More options 14 Sep, 11:35
From: Derek Fowler <dezfow...@gmail.com>
Date: Mon, 14 Sep 2009 11:35:15 +0100
Local: Mon 14 Sep 2009 11:35
Subject: Re: [luodn] MVC

You can have actions with the same name but you need to use the AcceptVerb
attribute and specify which verbs each is responsible for i.e. have one of
them handle the POST from the search form. Easiest thing is probably to just
have the action method expect two strings from the form and check
IsNullOrEmpty on each and decide what to do based on that.

2009/9/14 Thom Shannon <t...@glow-internet.com>

--
Derek Fowler
m. +44 (0) 7966 512 369
e. dezfow...@gmail.com

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Donovan Hide  
View profile   Translate to Translated (View Original)
 More options 14 Sep, 11:35
From: Donovan Hide <donovanh...@gmail.com>
Date: Mon, 14 Sep 2009 11:35:35 +0100
Local: Mon 14 Sep 2009 11:35
Subject: Re: [luodn] MVC
Actually, re-reading your post it seems like your problem is how to
re-render the page after a post. Simple answer is don't, maintain
state in the client and do an AJAX post with some jQuery to an action
which returns just the search results and inserts them into the DOM.
The Postback and ViewState models don't really transfer to MVC.

Cheers,
Donny.

2009/9/14 Donovan Hide <donovanh...@gmail.com>:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Paul Kinlan  
View profile   Translate to Translated (View Original)
 More options 14 Sep, 11:37
From: Paul Kinlan <paul.kin...@gmail.com>
Date: Mon, 14 Sep 2009 11:37:10 +0100
Local: Mon 14 Sep 2009 11:37
Subject: Re: [luodn] MVC

Hi Thom.
Used it quite a bit.

I find it better to separate everything out, sometimes a controller action
for each form is best.  In your case I would have a Search action on the the
controller that you are using.  Then on your view (web page) have two forms
with the same method and action but with different hidden variables
indicating the type.

// Controller action on the CompanyController
public ActionResult Search(string type, string term)
{

}

//In your view
<% using (Html.BeginForm("Search","Company")) {%>
    <%= Html.TextBox("term") %>
    <%= Html.Hidden("type", "department") %>
    <input type="submit" value="Find" />
<% } %>

<% using (Html.BeginForm("Search","Company")) {%>
    <%= Html.TextBox("term") %>
    <%= Html.Hidden("type", "code") %>
    <input type="submit" value="Find" />
<% } %>

But you get the freedom of who you want to do it and how you choose to
structure your controllers.

Paul

2009/9/14 Thom Shannon <t...@glow-internet.com>


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thom Shannon  
View profile   Translate to Translated (View Original)
 More options 14 Sep, 12:13
From: Thom Shannon <t...@glow-internet.com>
Date: Mon, 14 Sep 2009 12:13:46 +0100
Local: Mon 14 Sep 2009 12:13
Subject: Re: MVC

Thanks guys! That was all helpful.

We should get the luodn meetings going again :)

--
* Want to become an expert Digital Marketer?
www.glow-internet.com/bootcamp <http://www.glow-internet.com/bootcamp>

Glow New Media
t: 0151 707 9770
m: 07730 987 574
www.glow-internet.com

Suite 712 Gostins Building
32-36 Hanover Street
Liverpool
L1 4LN

Follow me at http://twitter.com/tshannon

Map: http://tinyurl.com/2f5nxd

Terms & Conditions Apply: http://www.glow-internet.com/home/terms.aspx


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Derek Fowler  
View profile   Translate to Translated (View Original)
 More options 14 Sep, 12:26
From: Derek Fowler <dezfow...@gmail.com>
Date: Mon, 14 Sep 2009 12:26:01 +0100
Local: Mon 14 Sep 2009 12:26
Subject: Re: [luodn] Re: MVC

Bit far for me to come now - suppose I could get a flight.

2009/9/14 Thom Shannon <t...@glow-internet.com>

--
Derek Fowler
m. +44 (0) 7966 512 369
e. dezfow...@gmail.com

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Adam Cooper  
View profile   Translate to Translated (View Original)
 More options 14 Sep, 21:13
From: Adam Cooper <a...@myogenic.co.uk>
Date: Mon, 14 Sep 2009 21:13:43 +0100
Local: Mon 14 Sep 2009 21:13
Subject: Re: [luodn] Re: MVC

You could also have two forms with different Ajax.ActionLinks  
specified and then return a partial with search results from each one.
To be honest I found the transition to mvc a bit painful, but like  
others have said well worth it once you can break out of the old  
webforms mindset and once you add jquery into the mix it's really fun.  
If you want I've a copy of the ASP.NET MVC 1.0 lying around I'm more  
than happy to lend. I'd also recommend the ASP.NET Framework book but  
I'm still half way through it so you'll have to wait a while for that  
one.
I think getting the luodn meetings going is a great idea btw.

On 14 Sep 2009, at 12:13, Thom Shannon wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thom Shannon  
View profile   Translate to Translated (View Original)
 More options 15 Sep, 11:20
From: Thom Shannon <t...@glow-internet.com>
Date: Tue, 15 Sep 2009 11:20:21 +0100
Local: Tues 15 Sep 2009 11:20
Subject: Re: MVC

Another question for you all.

I have a partial view and I want it to perform a simple action on the
server, but return the user to the current page. Do I have to post to
another action and then get it to redirect back to that page? What's the
right way to do that redirect while preserving all the parameters etc?
Just put the url in a hidden input or something? :-/

I get how I can use ajax but I don't want to depend on that, I like to
stick to progressive enhancement and get it all working first without.

--
* Want to become an expert Digital Marketer?
www.glow-internet.com/bootcamp <http://www.glow-internet.com/bootcamp>

Glow New Media
t: 0151 707 9770
m: 07730 987 574
www.glow-internet.com

Suite 712 Gostins Building
32-36 Hanover Street
Liverpool
L1 4LN

Follow me at http://twitter.com/tshannon

Map: http://tinyurl.com/2f5nxd

Terms & Conditions Apply: http://www.glow-internet.com/home/terms.aspx


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Derek Fowler  
View profile   Translate to Translated (View Original)
 More options 15 Sep, 11:26
From: Derek Fowler <dezfow...@gmail.com>
Date: Tue, 15 Sep 2009 11:26:08 +0100
Local: Tues 15 Sep 2009 11:26
Subject: Re: [luodn] Re: MVC

I dunno what the "right" answer is but could your controller inherit from a
common controller that provides the action method for your partial? You'd
have to record what the current action was so you could redirect back to
that action when your partial one is done.

2009/9/15 Thom Shannon <t...@glow-internet.com>

--
Derek Fowler
m. +44 (0) 7966 512 369
e. dezfow...@gmail.com

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Donovan Hide  
View profile   Translate to Translated (View Original)
 More options 15 Sep, 11:30
From: Donovan Hide <donovanh...@gmail.com>
Date: Tue, 15 Sep 2009 11:30:00 +0100
Subject: Re: [luodn] Re: MVC
http://stackoverflow.com/questions/1936/how-to-redirecttoaction-in-as...

TempData is your friend!

2009/9/15 Derek Fowler <dezfow...@gmail.com>:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thom Shannon  
View profile   Translate to Translated (View Original)
 More options 15 Sep, 11:34
From: Thom Shannon <t...@glow-internet.com>
Date: Tue, 15 Sep 2009 11:34:56 +0100
Local: Tues 15 Sep 2009 11:34
Subject: Re: [luodn] Re: MVC

I've used TempData a couple of times, it looks like a bit of a hack
really. I think I'll go with the hidden input option.

--
* Want to become an expert Digital Marketer?
www.glow-internet.com/bootcamp <http://www.glow-internet.com/bootcamp>

Glow New Media
t: 0151 707 9770
m: 07730 987 574
www.glow-internet.com

Suite 712 Gostins Building
32-36 Hanover Street
Liverpool
L1 4LN

Follow me at http://twitter.com/tshannon

Map: http://tinyurl.com/2f5nxd

Terms & Conditions Apply: http://www.glow-internet.com/home/terms.aspx


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael James  
View profile   Translate to Translated (View Original)
 More options 15 Sep, 11:38
From: Michael James <m...@mjjames.co.uk>
Date: Tue, 15 Sep 2009 11:38:48 +0100
Local: Tues 15 Sep 2009 11:38
Subject: Re: [luodn] Re: MVC
Personally I think the hidden input is more of a hack, tempdata is
provided by the framework to temporarily hold stuff whilst you perform
some logic, this sounds ideal for what you want to do. That way you
know there's no tampering.

Just my thoughts anyway.

--
Regards,

Michael James
m. 07793-113-556
e. m...@mjjames.co.uk
twitter. mjjames


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Donovan Hide  
View profile   Translate to Translated (View Original)
 More options 15 Sep, 11:39
From: Donovan Hide <donovanh...@gmail.com>
Date: Tue, 15 Sep 2009 11:39:25 +0100
Local: Tues 15 Sep 2009 11:39
Subject: Re: [luodn] Re: MVC
This chap just uses some lambdas and model mapping with
RedirectToAction to pass his state around actions:

http://jonkruger.com/blog/2009/04/06/aspnet-mvc-pass-parameters-when-...

Kind of depends how you've set up your models really.

2009/9/15 Thom Shannon <t...@glow-internet.com>:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thom Shannon  
View profile   Translate to Translated (View Original)
 More options 15 Sep, 11:43
From: Thom Shannon <t...@glow-internet.com>
Date: Tue, 15 Sep 2009 11:43:41 +0100
Local: Tues 15 Sep 2009 11:43
Subject: Re: [luodn] Re: MVC

but how do I get the current page into tempdata in the first place? I'd
have to put it in there during the execution of every single action,
plus it's session scoped so if the user has more than one page open
they'll get redirected back to the last action executed rather than the
one they just came from.

--
* Want to become an expert Digital Marketer?
www.glow-internet.com/bootcamp <http://www.glow-internet.com/bootcamp>

Glow New Media
t: 0151 707 9770
m: 07730 987 574
www.glow-internet.com

Suite 712 Gostins Building
32-36 Hanover Street
Liverpool
L1 4LN

Follow me at http://twitter.com/tshannon

Map: http://tinyurl.com/2f5nxd

Terms & Conditions Apply: http://www.glow-internet.com/home/terms.aspx


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Donovan Hide  
View profile   Translate to Translated (View Original)
 More options 15 Sep, 11:57
From: Donovan Hide <donovanh...@gmail.com>
Date: Tue, 15 Sep 2009 11:57:09 +0100
Local: Tues 15 Sep 2009 11:57
Subject: Re: [luodn] Re: MVC
Ahh, session state, another ASP.NET legacy! It doesn't translate well
to MVC. Current page can be determined by your url, or current action.
Might be worth looking at filters if you need something to be run
before every single action. Create a BaseController and define your
filters in there.

Are you doing a search form that will be on every single page of a site?

2009/9/15 Thom Shannon <t...@glow-internet.com>:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thom Shannon  
View profile   Translate to Translated (View Original)
 More options 15 Sep, 12:11
From: Thom Shannon <t...@glow-internet.com>
Date: Tue, 15 Sep 2009 12:11:06 +0100
Local: Tues 15 Sep 2009 12:11
Subject: Re: [luodn] Re: MVC

It's a "switch user" for admin.

It's working ok now, like so...

using (Html.BeginForm("ChangeClient", "Admin", FormMethod.Post, new { id
= "ChangeUser" }))

{ %>

    <%= Html.DropDownList("clientid", (from c in new
DataDataContext().Clients orderby c.Name select new SelectListItem() {
Value = c.ClientID.ToString(), Text = c.Name, Selected =
(Session["CurrentClient"] == null ? false : c.ClientID ==
Session["CurrentClient"] as int?) }).ToList())%>

    <%= Html.Hidden("currentpage", Page.Request.Url.PathAndQuery)%>

    <input type="submit" value="Change" />

<%

public ActionResult ChangeClient(int clientid, string currentpage)

{

    Session["CurrentClient"] = clientid;

    return Redirect(currentpage);

--
* Want to become an expert Digital Marketer?
www.glow-internet.com/bootcamp <http://www.glow-internet.com/bootcamp>

Glow New Media
t: 0151 707 9770
m: 07730 987 574
www.glow-internet.com

Suite 712 Gostins Building
32-36 Hanover Street
Liverpool
L1 4LN

Follow me at http://twitter.com/tshannon

Map: http://tinyurl.com/2f5nxd

Terms & Conditions Apply: http://www.glow-internet.com/home/terms.aspx


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google