State management form post problem

Hi everyone!

This is my first post at asp.net. I'm developing a web application using MVC and I have a doubt. There's a page named "My Account" where the user can edit his data (change his phone, address etc). So, this page gets all the user data from the database and fills all TextBox, DropDownList etc dynamically. To do this (gets data from DB), I use:

1    [Accept(Http.verbs.Get)]
2    public ActionResult UserDetail
3    (...)
4    ViewData["nome"] = u.nome;
5    ViewData["sexo"] = u.sexo;
6    ViewData["ocupacoes"] = _ocupacaoServico.SelecionaOcupacoes();
7    ViewData["selOcupacao"] = u.codOcupacao;
8    ViewData["telRes"] = u.telRes;
9    ViewData["telCom"] = u.telCom;
10   ViewData["telCel"] = u.telCel;
11   (...)

and when I do the post to save all the user's changes, I redirect to the same action. I use a try catch to Update user details (this.UpdateModel) and when I return to the page after doing the post, I show all the user's details updated. That works just fine.

However, if I got a exception, the only way the form shows the details is through the ViewData... if I use 'return View ("myObjectModel")' that doesn't work. So, to work fine, I have to write all ViewData["userDetail1"]s and that's very boring.

 Anybody knows how to do that?

Thanks in advance!

Andre

 
0
acymiranda
11/6/2008 5:49:32 PM
asp.net.mvc 4300 articles. 0 followers. Follow

0 Replies
824 Views

Similar Articles

[PageSpeed] 38

Reply:

Similar Artilces:

Need help for solving MVC form post problem
Hi all First of all, please accpet my apology for my poor English. I got a problem posting data to the Controller. Now I have a master page which includes one tree view in my left site of the main page (That means i need a form with "runat=server"). In the right site of the main page(ContentPlaceHolder), the page allows use to update ther own information(That means I need a form that post data without "runat=server" to the controller). So I have got problem cuz in the main page i need a "runat=server" form(cuz of...

Microsoft Chart control for .NET Framework about state management and serialization problem, it works OK with one XML file but fails with another XML file
I use Microsoft Chart control for .NET Framework , you can see details at http://blogs.msdn.com/alexgor/archive/2008/10/27/microsoft-chart-control-for-net-framework-released.aspx The Chart1 is load data from a xml and save to ViewStateData, so even if after I click Reload button, the chart1 still display OK! I'm very strange that the chart1 works well after click Reload button if it's loaded from Chart1.Serializer.Load(HttpContext.Current.Server.MapPath("~/Template/1.xml"));but chart1 don't display fter click Reload button if it's loaded from Chart1.Serializer.Loa...

Unusual problem where form parameters are not being passed to a .NET form
Hi, I am using Visual Studio 2005 on Windows 2003 (64 bit) and have a very unusual problem and would appreciate any help. Requirement - The Web application is part legacy part ASP part .NET. I have a requirement to show a Cyrstal PDF report in a new browser window. To do this I load and auto submit an ASP form which submits to a .NET form that opens in a new window. The .NET form generates the Crystal PDF file and response.redirects to display the report in the new window. Problem - On my development manchine (which hosts the web server) the application works as planned. Howeve...

Post form with data to a external site (.net 1.1 vb.net)
Hi I have now been googling for hours and I can not find a answer. :-( I am programming a e-shop (.net 1.1) and what I want to achive is: Customer fillout form, clicks on the Pay button then should the following thing happen: 1. Form date is saved to the database ( normal vb.net code ) 2. The data that should be posted to the external form is create from the saved data   ( normal vb.net code ) 2. A post is done to an external site with created data as "post" data and then user is redirected to this site. Thanks   Christian   Use the System.Net.HttpWebRequest...

State Management Problem
I am using a datagrid to display a report that is generated from a detailed search screen. The datagrid needs to be both pageable and sortable. The dataset that is used to populate the grid is large, around 11 columns and 500 rows on average. What is the best option for maintaining this dataset across post backs? I was going to cache the dataset on the webserver and then create filtered views of the data; however, because of the comlicated search the processer gets pegged out when trying to filter. It is not feasible to requery for each page change and sort as I am pulling data from...

Form posting problem
Here's my situation. I have a form with several textboxes with an update button. I populate the textboxes with the corresponding fields data from a sql call to sql server's recordset. Now, when a user hits the update button, it should update the database by using an update statement. My problem is, its not working. Its not updating the SQL database. Some how when the submit button is hit. It doesn't retrieve the info from the textboxes Is there some issues I should be aware of? Website that can give a clue on this? Here's the code i use Private Sub btnSubmit_Cl...

problem submitting form in html mail for forms with method="post"
Name: Tommy Daniels Product: Thunderbird Summary: problem submitting form in html mail for forms with method="post" Comments: I know this is already a reported bug but I'd love to see this fixed or even a work around. ...

form post problem
Can I use a form and post it back to same page and pass a query string in asp.net like in classic asp? <form id="frm1" method="post" action="samepage.aspx?from=xxx" runat="server"> I'm trying to do this and when user clicks submit button trying to access the value "from" by using request.querystring("from"). How come this is not working??? There are lot of post backs in my page I'm trying to do somethings when user submits the form. Thank you Age There are lots of ways to detect what caused a postback i...

Forms, POST problem
I have a simple HTML form that explicitly sends a POST request to a .aspx script, where I process the submitted variables. I personally have never had any problems using it, however sometimes, when someone else uses it, data will get POSTed, and I might also see a HEAD or GET request, or I might even see the POST data listed in plain text in the HTTP_REFERER address. Does anybody know what's going on? The form is explicitly set to send POST: <FORM NAME="myform" ACTION="myscript.aspx" METHOD="POST" ONSUBMIT="return DoCheck()"> Why would H...

Post form with data to a external site (.net 1.1 vb.net) #2
Hi There I am programming a e-shop (.net 1.1) and what I want to achive is: Customer fill out form, clicks on the Pay button then should the following thing happen: Problem is that I need to do a "Clean post" like if the user would have pressed the submit buttom on a normal HTML page I don't need the result in the ASP application, the external site will take over from there. The syntax are ASP.net local application : form data is save in a local db ASP.net local application : A POST string is created ( I could create a FORM in real html but then the use has to press twice) The ...

State Management; .Net Profiler
Here is the situation with the customized profiler. I got a profiler class called SSOProfileProvider inheriting from ProfileProvider. I've implemented the Initilization, GetPropertyValues and SetPropertyValues. The Get... and Set.. are making a call to the database to store profile into the database. This class has been stored in the separate DLL called "Security.DLL" and there is a web site that is using this dll. The web.Config for this website is as follow:<profile enabled="true" inherits="AppProfileBase" defaultProvider="SSO" automat...

State Management in Web Forms
This article discusses the ways in which the state management can be handled in web forms. State management can be done either on client side or server side as explained below. Author-Jalajakshi Venkataramana http://www.dotnetbips.com/displayarticle.aspx?id=247...

Form Post problem #2
Im trying to use this Form from PayPal. It is copied straight from their site. <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_cart" /> <input type="hidden" name="upload" value="1" /> <input type="hidden" name="business" value="seller@designerfotos.com" /> <input type="hidden" name="item_name_1" value="Item Name 1" /> <input type="hidden" name=&qu...

Need to keep form state and load form state from file
I have a form with regular html selectboxes (controlled by javascript to push items around the selectboxes). I need to find a way to keep the state of these items even after an asp.net button click event (which loads some session variables with the values of the form and makes a page.registerstartupscript for opening search results in a new window). I was thinking that the same principles used when keeping the state might also be useful for loading the state from a specially formatted file. At the moment I try the following: - on submit of form the hiddenfields are loade...

Web resources about - State management form post problem - asp.net.mvc

Management - Wikipedia, the free encyclopedia
Management in business and organizations is an art that coordinates the efforts of people to accomplish goals and objectives using available ...

Management - Wikipedia, the free encyclopedia
Management in business and organizations is the function that coordinates the efforts of people to accomplish goals and objectives using available ...

Management - Wikipedia, the free encyclopedia
Management in business and organizations is the function that coordinates the efforts of people to accomplish goals and objectives using available ...

Management - Wikipedia, the free encyclopedia
Management in businesses and organizations is the function that coordinates the efforts of people to accomplish goals and objectives by using ...

TDM Asset Management reveals the importance of culture for investing
By investing on its own terms, TDM Asset Management is challenging the norms of funds management.

Ex-employee: Rare’s management to blame for Kinect focus, not Microsoft
... But in an interview with Eurogamer , ex-Rare designer and current Playtonic studio director Gavin Price explained that it was Rare's management ...

Video Of The Week: Community Based Portfolio Management
My colleague Brittany Gorevic gave a talk at the Slush Conference a last month about how we use community to help our portfolio help each other. ...

Apple CEO Cook Slams Tax Policy on ’60 Minutes’; Street Reviews Management Shuffle
Coming up this weekend on “60 Minutes,” Apple ( AAPL ) CEO Tim Cook talks with Charlie Rose on a number of topics, including repatriation of ...

Microsoft Office 365 now offers a project management app
Microsoft has announced the release of a preview and testing version of its new lightweight project management application Planner. The application ...

Seattle firm Rainier Investment Management acquired for $3B
Seattle-based Rainier Investment Management on Friday announced plans to will be acquired by New York-based Manning & Napier, Inc. (NYSE: MN) ...

Resources last updated: 12/24/2015 7:20:38 AM