C# - Form Values Do Not Get Transferred To HttpPost From View?
Mar 17, 2011
Here is my Controller:
public ActionResult Deposit()
{
return View();
}
[HttpPost]
public ActionResult Deposit(DepositTicket dt)
{
using (var db = new MatchGamingEntities())
{
MembershipUser currentUser = Membership.GetUser();
Guid UserId = (Guid)currentUser.ProviderUserKey;
var AccountId = from a in db.Accounts
where a.UserId == UserId
select a.AccountId;
BankTransaction transaction = new BankTransaction();
transaction.Amount = dt.Amount;
transaction.AccountId = AccountId.SingleOrDefault();
transaction.Created = DateTime.Today;
transaction.TransactionType = "Credit";
Debug.Write("Amount: " + transaction.Amount + " AccountId " + transaction.AccountId);
db.BankTransactions.AddObject(transaction);
db.SaveChanges();
return View();
}
}
Here is my View:
[Code]....
View 1 Replies
Similar Messages:
Feb 23, 2011
Simple question. I have an mvc controller that has method:
[code]....
The form is a non-trivial form with a simple textbox.
Question - how on earth do I access the parameter values? I am not posting from a View, the post is coming externally. I'm assuming there is a collection of key/value pairs I have access to. I tried Request.Params.Get("simpleTextBox"); but it returns error "Sorry, an error occurred while processing your request.".
View 3 Replies
Sep 3, 2010
I am just getting started with MVC after many years of WebForms development.
I have a very simple page with two textbox fields, one called Input where a user will enter something, and one called Output where I want to return some string after they post the form, much like a postback scenario in WebForms. I have the View connected to a ViewModel for strong typing.
The ViewModel:
[Code]....
The View:
[Code]....
The Controller:
[Code]....
The problem I have is that the output text "Here is some response" never gets displayed, even though I modify the value in the HttpPost method and return the viewmodel to the view. Unless (just tried it) I set the textarea to disabled with:
[Code]....
Can someone explain this behavior? It seems as some "magic" assumes that whatever was in the input fields before the HttpPost should also be there after the post, similar to what ViewState does in WebForms.
View 2 Replies
Apr 13, 2010
I set a breakpoint on my httppost view and found that the value from a checkbox field was 'true,false" even though it was checked..how come it displays both values?
I created the create template using editorformodel(). The field using this checkbox is of bit datatype.
The action code is below;
[Code]....
View 3 Replies
Jul 30, 2010
I'm trying to pass the Question parameter from SubmitAnswer to Index.. But it's not working that well...
Code:
[Code]....
View 7 Replies
Sep 10, 2012
I have a formview that I want to prepopulate some values based on some dropdowns that the end user chooses.
The formview is in insert mode tied to a datasource so the insert will be easy because it is tied to a dataset.
Just thinking of best way to prepopulate these fields. I am going for a best practice these days.
The one way I planned on doing it, was after they selected the dropdowns I will grab the values from the datasource and do a findcontrol on the formview to populate them.
View 1 Replies
Jan 23, 2010
I have a form view with a couple of text boxes on them. I want to make the text values available elsewhere on the form I have been trying
View 3 Replies
Jun 23, 2010
I have a view with a form..this form has a textbox and a checkbox in it.
i also have a submit button in the form which points to an action in a controller.
my question is..how can i pass the values in the textboxes and the checked state of the checkboxes to the controller action? the textboxes and checkboxes are not tied to a model.
View 7 Replies
Mar 26, 2016
With reference to the following link [URL] /How can i save to database Gridview1 data which was tranfered from page1 to page2
View 1 Replies
Jan 18, 2011
I've been building an MVC 2 site on my local machine which I then hoped to FTP to my companies IIS7 server.
When I first started using the MVC in VS2010 I published in VS via FTP and everything was fine, asp.net was properly installed and the mvc library was there.
Now I'm faced with a problem that I can hardly define, let alone get around:
When I attempted to publish, the controller folder wasn't being transferred, so I manually copied it across thinking it was just an FTP problem, but then I got errors complaining about an assembly reference in my web.config file:
Parser Error Message: Could not load file or assembly 'System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
So I'm guessing that whatever it is that is preventing VS transferring the controllers folder is doing the same with some of the MVC configuration stuff.
Another oddity is that thought the initial settings worked, I've since scrapped the orignal project and started again, I've had a look back at it and tried to use the original settings to FTP across but they now don't work and have the same problem, as does my bosses machine(previously unused version of VS) when I tried to FTP across the default MVC2 project.
VS reports that the FTP publish has succeeded and the controller files aren't listed in the Publish.XML file on either machine.
View 5 Replies
Nov 22, 2010
I was told to use a Repeater control in what I am doing which is a "Data Entry" screen with ASP.NET controls -a standard "address" like form. In cases, the fields on the form will repeated twice, once for the original values, one for the changed values. I have not used this control before but it seems like I have to bind to a database. Instead, I have an Entity object that has been obtained via a Repository. Can I bind to an object like this?
[DataContract()]
public class RON
{
[code]...
View 4 Replies
Sep 4, 2010
I want to use a grid in asp.net MVC application. I did an evaluation and found JQgrid to be optimum from performance point of view(minimum posback). What is your views about this and suggest if you have any other grid in mind which performs better and which is free of cost for commercial usage. Also now a want to post data from edited grid back to server from Jquery base JQgrid .Should i do it using httpget or httppost. If i use HTTPPOST, what should i calculate in controller and what in model As per examples available on net, people are putting calculation logic in controller(See article [URL] I need to know whether it is good practice to put business logic in controller rather than restricting it for routing to view and model.
Controller code as given in mentioned website is having following code
public ActionResult DynamicGridData
(string sidx, string sord, int page, int rows) {
var context = new HaackOverflowDataContext();
int pageIndex = Convert.ToInt32(page) - 1;
int pageSize = rows;
int totalRecords = context.Questions.Count();
int totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize);
var questions = context.Questions
.OrderBy(sidx + " " + sord)
.Skip(pageIndex * pageSize)
.Take(pageSize);
var jsonData = new {
total = totalPages,
page = page,
records = totalRecords,
rows = (
from question in questions
select new {
i = question.Id,
cell = new string[] {
question.Id.ToString(), question.Votes.ToString(), question.Title
}
}).ToArray()
};
return Json(jsonData);
}
design practice and sample to implement grid with HTTPpost feature
View 3 Replies
Jan 3, 2011
How to carry values from "Form to Form" in ASP.net using vb.net?
View 2 Replies
Feb 28, 2011
I have two asp.net applications webapp1 and webapp2, in each application i have a asp.net form Deafult.aspx
I want to do a form submit from Default.aspx in webapp1 and recieve the value in webapp2.
I tried to do it with simply setting action ="webapp2 location" but it is throwing the bellow error
Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.
I even added the machinekey element to web.config
but it is still showing the same error.
This is the code for webapp1 form which sends data to webapp2
[Code]....
View 2 Replies
Feb 11, 2011
I have a partial view that is rendered on a view. That partial view has textboxes in it. The user can enter values into them.
I need to put all the values from the textboxes in my partial view into an array, and then give the view (the parent page rendering that partial view) access to that array.
View 6 Replies
Nov 22, 2010
I am using a view to create some new categories in the DB but the object the [httpost] create method receives is empty, now this does not always happens. I did double check with other catalogscontrollers and so far the implementation is the same... It only happensds when i try to create a new category the CategoryController
[Code]....
the ViewModel
[Code]....
my create view is strongly typed to ViewModel and has this relevant code create.aspx
[Code]....
and my ascx file is strongly typed to the entity model directly. when the "create" button is pressed and Exception is catched and returns the same view... I have implemented this for other catalogs and works fine except for this one...any clues... by the way i´m using entity model ...
View 3 Replies
Aug 4, 2010
I am using a from view for data entry. I need to verify that a check box is true or false after editing a record.
I have been accessing label text using the following|
CType(FormView1.FindControl("RespDeptLabel"), Label).Text
How can I access the state of a checkbox in the form view to determine if it is true or false
View 4 Replies
Jan 24, 2010
In my website I have two forms: parent form and child form(dialog box). Their expected behaviour is like this: if clicked on 'show' button on parent form, a dialog form opens that displays a gridview. In dialog form, if clicked on 'select' button it closes
itself and returns value in selected row back to parent form.
To achieve this I write following code (.cs) : in parent form:
void ShowBtn_Click(object sender, EventArgs e)
{
StringBuilder jScript = new StringBuilder(); [code]....
Now problem is: the code in parent .cs works fine, it opens the dialog properly. But when clicked on 'select', instead of returning back to parent, it opens the same dialog again in new window. This newly open window says "Done but error on page" at left bottom.
View 6 Replies
Jan 7, 2011
I am only start learning MVC 2.I have class
[Code].... I wrote HttpPost in controller
[Code]....
my page has next code:
[Code]....
Why InvoiceFinalViewModel view, List<Product> products parameters came with null and zero value in post ?
How correct bind arrays in MVC ?
View 12 Replies
Mar 27, 2011
I have an Index view that shows a list of employees and a Create partial view with a form and submit button to create employees. In the Index view, I have:
@{Html.RenderAction("Create");}
A user sees a blank form to create employees and a list of employees. After the user has typed data in the form and clicked the submit button, the form should become blank and the list of employees should be refreshed, showing employees plus the new employee.
The problem is I don't know what to return from the Create action:
public ActionResult Create(Employee employee)
{
return ???
}
View 12 Replies
May 20, 2010
I have just started using MVC2 in VS2010, and I noticed that on the Register page DataType.EmailAddress doesn't actually do any validation, so it does not check whether or not the Email Address entered is valid. Should I write some email validation code in the HttpPost Register method of my AccountController, or is there another way to do this?
View 1 Replies
Mar 14, 2011
I have a grid view which displays some values. now i have to calculate row wise sum of those values for each row and then display against them.i tried this code but i am getting error as Input String Was not in Correct Format.
public void gv_RowCreated(Object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
int total = Convert.ToInt32(e.Row.Cells[1].Text) + Convert.ToInt32(e.Row.Cells[2].Text) + Convert.ToInt32(e.Row.Cells[3].Text) + Convert.ToInt32(e.Row.Cells[4].Text) + Convert.ToInt32(e.Row.Cells[5].Text) + Convert.ToInt32(e.Row.Cells[6].Text) + Convert.ToInt32(e.Row.Cells[7].Text);
((Label)gv.FindControl("Label8")).Text = Convert.ToString(total);
}
}
View 2 Replies
Jun 20, 2010
I'm using HttpModule to capture requests to the web server. Before processing the page I'd like to check the values contained in some keys of the Request.Form collection and according to some logic change if necessary. I'd like to do this when BeginRequest event is fired. The problem is that the Request.Form collection is readonly.
View 4 Replies
Aug 10, 2010
I am having 3 cascaded drop downlists and a many check boxes. On Click of button i want the all the values of Selected items. How can i achieve this. I know that this can be done by having a action method with HttpPost attribute. But the dropdown lists are not strongly typed with my model.
View 3 Replies
Apr 6, 2011
Details :
Visual Studio 2005 - Vb.net
Windows XP Sp2
Sql Server
I am a very new learner to asp.net. guide me with some example. My problem is that when we use formview with some sqldatasource bind to it. want to use Dropdown list in it to select the item.... i.e if using some employees list... data to be displayed on the EMPLOYEE NO selected in the dropdown list. Further in the edit/insert/update mode values to be updated on the values selected in in other dropdown lists like post from Dropdown list showing posts which is fetched from any other table.
View 1 Replies