MVC :: Send ActionResult View As EmailTemplate

Jul 10, 2010

I am trying to implement a way to send email templates in my application and would like to populate an ActionResult view with data and then output the view HTML as a string to use as the body of my email. I found the following

blog post but have not been able to get it to work correctly in my app and was wondering if anyone had been able to implement something similar. The issue that I am running into is that I have created one controller, EmailController, to handle all generation and returning of the the view strings. So for instance if I am in my home controller and I have a contact form whose action is Contact when the user submits the contact form I want to call the email controller to get the correct action result for the email template and upon successful send of the email redirect the user to a success action on the home controller.

View 1 Replies


Similar Messages:

MVC :: Partial View Not Sending View Model To ActionResult Method?

Dec 29, 2010

've created a Search partial view and it works, except for my view model. What i mean is, the partial view sends a string to my ActionResult Method, but only a string, that is not related to the view model that the partial view is built in. If i tell my ActionResult method to receive the view model in which the partial view is built in, it always tells me that i have null values. Here's my code This is my partial view:

[Code]....

Now here is my Model in my MoviesSearch view model:

[Code]....

Now the actual MoviesSearchViewModel

[Code]....

Inside my Search controller i have this

[Code]....

And then i have this:

View 1 Replies

How To Use An Actionresult To Return Both A View And A Partial View

Feb 17, 2011

How can I use use an actionResult to return both a view and a partial view. Actually in case of an ajax request it should send a partial view else it should send a view.

public ActionResult Test(string Name ="", DateTime? Date= null, string sex="" )
{
myModel model = new myModel(Name, Date, Sex);
if(IsAjaxRequest)
return PartialView("partialView", model)
else
return View(model);
}

View 1 Replies

C# - MVC ActionResult View() Not Changing Url?

Feb 6, 2011

I have a method...

[HttpPost]
public ActionResult Start(SomeViewModel someViewModel) { ... }

that based on some conditions returns things like return View("Invalid"), View("NotFound"), View("Run", anotherViewModel), etc. The problem is that no matter what view I present, the URL does not change to reflect the new controller/action. This poses a problem when my View wants to post to a different action. How can I fix this?

View 2 Replies

MVC :: Two ActionResult In A Single View?

Aug 19, 2010

Shall i able to create two actionresult in a single page?

I m using two Html.BeginForm() in a single page? These two forms has different data as like

BeginFrom1() - dropdownlist

<% using (Html.BeginForm("ViewByStatus", "NewsLetterAdmin", FormMethod.Post))
{ %>
<div>
Filter:
<%=Html.DropDownList("statusName",new SelectList(new[]{"#firstname#","#lastname#","#emailid#","#date#"}))%>
<input type="submit" value="?" />
</div>
<%} %>

BeginForm2() - textbox , freetextbox
<% using (Html.BeginForm("ddown", "NewsLetterAdmin", FormMethod.Post))
{%>
<fieldset>
<legend>Fields</legend>
<div>
<%= Html.LabelFor(model => model.TemplateName) %>
</div>........

When i select a dropdownlist and submit , dropdown selected value comes to textbox and freetextbox. Its working well

Again i m adding contents to freetextbox

Again i select a dropdownlist and submit , dropdown selected value comes to textbox and freetextbox. The newly selected value only comes to textbox and freetextbox, but my old contents are not exists in freetextbox.

I need old contents and dropdown selected value comes to freetextbox.

View 3 Replies

MVC :: What View Is Used When Calling A Controller Method Without ActionResult

Jan 9, 2010

I have just started using MVC. I created the MVC application and was playing around with it.When you call the http://localhost/home/Index/ on the sample MVC application the Index method of the controller home gets invoked and the view Index.aspx is displayed and similarly when we call http://localhost/home/About/ then the About method of the Home controller is invoked and the About.aspx page is displayed

View 2 Replies

MVC :: How To Pass A Value Form ActionResult To Html.textbox Or Html.TextBoxFor In View

Mar 18, 2010

how can i passing a value form ActionResult to html.textbox or Html.TextBoxFor in View

View 2 Replies

MVC :: How To Get The One Actionresult Data To In To Other Actionresult

May 21, 2010

this is the first controler which is calling my applciation I am getting all my studentinfo for updating studnetcan i call this et in updateresult Action result?

public ActionResult getresult(StduentInfo et)
{
return PartialView("Student", et);
public ActionResult updateresult(Stdentinfo et)
[code]...

View 1 Replies

C# - Can Send Different View Models To A View?

Feb 4, 2011

I am implementing a view for Food. (ASP.NET MVC2) Then depending on the type (say fruit or vegetable for example) I will change the view.

Can I do this without creating a seperate view for fruit and vegetable?

I.e. Say we have url structure like [URL] and don't want [URL] [URL]

So I want to be able to change the view depending on the type. I'm using a tabstrip control from telerik, to give you an of the difference in the views - it'd just be say - not displaying one particular tab for Veg, and displaying it if fruit, for example.

Can a view accept two different view models ? so when we hit [URL] the code determines what type the object is (Fruit or Vegetable) then sends either FruitViewModel or VegetableViewModel ? If I just send one viewmodel how can I control the logic to display or not display certain things in the view?

View 3 Replies

How To Send Id From View To Controller

Mar 27, 2011

I have a view that receives a Model and displays info of that model.

I have a submit button and when it is clicked i want it to send the id to the method to process it and delete a row that has such id.

How can I do this? I want to use a button not an html link like

@Html.ActionLink("Delete", "Delete", new { id = Model.Id }) |

View 1 Replies

AJAX :: How To Send The Value Grid View

Dec 24, 2010

I have a grid view in which I have table.On Click of a particular td in the grid I open a modal window of ajax.I want to send the id of a particular row to the modal window.Here is the Code for aspx.

<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False"

View 1 Replies

MVC :: Error With Send A List Of Data To View?

Apr 3, 2010

when i send data for show a list of the project to view i got this error

The model item passed into the dictionary is of type 'BentaAccounting.Models.Project', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[BentaAccounting.Models.Project]'.

the Inherits view is

System.Web.Mvc.ViewUserControl<IEnumerable<BentaAccounting.Models.Project>>

and by this method Retrieval data

[Code]....

View 6 Replies

Data Controls :: Pass (Send) Values From One View To Another In MVC?

Jun 16, 2015

I am doing loan sysytem where you first select the amount you want to borrow and click apply. the problem im getting is i cant seem to be able to redirect the amount selected to my second view where the client fill up the form.

View 1 Replies

Web Forms :: Can Use Send Button Image To Response Or Redirect To The View Message Page

Jun 7, 2010

I'm rewriting a messaging module and the old asp application has a send button image and it used HTML submit button. My new application is asp.net. Can I use the asp send button image to response.redirect to the View message page?

View 3 Replies

Forms Data Controls :: Send Multiple Mail Using Checkbox In Grid View?

Jun 14, 2010

I want to send mail to those user which is selected using checkbox which is in grid view, and also want select all/ deselect all option .

[URL]

i go through this but this is not send mail to user more than one.

View 2 Replies

MVC :: Sending Value To ActionResult?

Jun 15, 2010

I have a dropdown with several items (hardcoded) and next to it I have a submit button - which invokes an Action in the controller. I can successfully identify the submit button in the controll using the name and value attributes of the submit button, but how can I send the selected value of the dropdown control to the controller?

[Code]....

Then inside the controller I can identify that the submitButton with value of "Start Task ..." has been clicked, but I do not know how to know which value in the dropdown was selected?

[Code]....

View 5 Replies

MVC :: ActionResult To Appear In New Window?

Sep 17, 2010

our implementation of an mvc site is being done in a very weird way but none the less it is still mvc.

I have an issue that on a certain page, when you click a button to download a document, it retrieves from a web service a byte array of a document. This is not an issue as i pass this byte array into the view data to allow me to access it in our controller.

This is the code in the controller.

[Code]....

Now this all works ok but as expected the result is rendered out into the current window. Is there anyway at all i can trigger a new window to render out the document?

View 2 Replies

MVC :: Custom Routes For 5 Different ActionResult()?

Apr 6, 2010

I'm creating a new ASP.NET MVC 2.0 web application that will have 5 main pages:


- Home
- Services
- Contact Us
- Terms & Conditions
- Priva

View 2 Replies

MVC :: Testing ActionResult.ExecuteResult?

Jan 15, 2010

I have the following action result class that looks for a content type of "application/json" in the request and executes a jsonresult or the default result. My problem is that I don't know how to test the ExecuteResult method.This is the method in question:

[Code]....

View 1 Replies

MVC :: ActionResult Not Called From Input?

Jan 1, 2010

to make sure, that my problem is not made by myself i create a new mvc solution and added following code into Views/Home/Index.aspx:

[Code]....

The corresponding HomeController was added by following Code:

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult SendMail(string username, string email, string subject, string message)
{
ViewData["Message"] = "Mail was sended....";
return View();
}

The ActionResult was not called - what do i have to do else? What do i forget?

I made a look to the Orange-Template where i found to do it in that way and in that Template it works.

View 13 Replies

MVC :: Authorize ActionResult By User?

Mar 25, 2011

I know i can authorize an action result for named users

[Code]....

but how do i do it for an unknown username? so i have the username stored in the database

View 4 Replies

MVC :: Action Returning More Than One ActionResult?

Feb 25, 2010

I have an action that returns a file path as ActionResult, I want that action to return a file path and change the View. Is there a way I can make an action return more than one ActionResult?

View 10 Replies

MVC :: Pass Parameter To ActionResult Method?

Mar 17, 2011

I have an ActionResult Method defined as following;

[Code]....

I am using JQuery and would like to know how I call this method passing a parameter. I have the following which does not work;

[Code]....

View 1 Replies

How To Change Default Controller Actionresult

Jan 8, 2010

By default ASP.NET MVC uses ContentResult for controller method that return result not inherited from actionresult type. That is why if we will return some poco entity it will be only its type name.Could I overload something in controller to make it return jsonresult by default.Example:// return json product representation instead of product typename

public MyController: Controller
{
public Product MyAction()
{
return new Product { Name = "Foo", ID = 1 };
[code]...

View 1 Replies

C# - How To Reduce The Number Of Parameters In An ActionResult In MVC

Feb 15, 2011

[Code]....

Is there any other way to make this more efficient?

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved