MVC :: Delete Method In A Controller?
Feb 4, 2011when i create a controller with create ,delete , etc method
then how to use delete and edit method and what is id parameter in these method.
when i create a controller with create ,delete , etc method
then how to use delete and edit method and what is id parameter in these method.
I am using VS 2008 SP1. My also have included CSS Friendly adapter [URL] in my project ( I mentioned this because my GridView Empty data template is not showing when using GridView's CCS Friendly adapter). I have a GridView and a DetailsView. When a record in GridView is selected its details information is shown in the Details View. Type of Data source I am using is ObjectDataSource. My Insert and Update methods works perfectly. It is only the Delete method that is passing null values to the underlying object delete method. My source codes for both the UI, BLL, DAL is shown below
[Code]....
My Business Object code is below :
[Code]....
My Data Access Layer Code is:
[Code]....
How can i transfer control to a controller's method from a controller's method..I am having two Controllers Home and User.. After username and password are verified inHome Controllers method , i want to show the User Controllers index page , so i have to callindex method of Home controller..How can i do it.
View 5 Replies my MVC2 delete and only my delete controller is refusing to return any class information. Its really similar to my edit function and the views are all auto-generated so I don't see the problem.
Function Delete(ByVal id As Integer) As ActionResult
This is my Controller class:
[Code]....
This throws the System.Reflection.AmbiguousMatchException. When I comment the second (HTTP-Post) Create method, it works fine.
I have a foreach in my view and inside foreach I create a control with unique name:
[Code]....
so, form can have checkboxes:
<input type="checkbox" name="IsProjectA" />
<input type="checkbox" name="IsProjectB" />
<input type="checkbox" name="IsProjectSomeName" />
how to get their values on post method controller (what is the best way).
I'm very new to MVC so this is a simple issue, just can't seem to find any information on why it's happening so turning to the forums. Edit works, delete sort of works (that's another issue in itself), and details works, but create causes an issue. I've debugged the form being passed in and it's always null with default values. It's almost identical code to my edit so I'm not sure why edit works and create won't. I'd show code for the view but since it's working for edit I'm currently ruling that out as the problem. "Colleges" in this populates a dropdown in the view. Here's the code:
[Code]....
i have created a controller method that just update a record in the database.
and i call this method using the following code
<%
: Html.ActionLink("Perform
Calculation",
"Calculate")%>
but the problem is that when i click on the Perform Link an error will be raised indicating that it can not find the Calculate view.
so how i can enforce my application to call the Calculate controller method to perform the update and to keep the user in the current page .(the index page).
I am having trouble finding any information on this but basically in MVC how do I set up a controller method do read a GET request? For example I have the following url,
http://www.mysite.com/events/eventsearch?sdate=31/10/2010&edate=31/12/2010&group=3
Do I just do the following?
[Code]....
I just do not understand how to handle the GET requests in ASP MVC.
I have a JSON object in javascript
it is a collection of Object
How can I pass this object to a controller if i am submitting the form like
$('#myform').submit();
what object type should i give for the parameter to accept this Json
I am fairly new to MVC and just trying to achieve something which I think shouldn't be too complicated to achieve. Just want to know what the best approach for that is. I have an Event-RSVP application (NerdDinner kind) where you go to view details of the event and then click on an AJAX link that will RSVP you for the event.
<%
if (Model.HasRSVP(Context.User.Identity.Name))
{
%>
<p>
You are registered for this event!
<%:
Ajax.ActionLink("Click here if you can't make it!", "CancelRegistration", "RSVP", new { id = Model.RSVPs.FirstOrDefault(r => r.AttendeeName.ToLower() == User.Identity.Name.ToLower()).RSVPID }, new AjaxOptions { UpdateTargetId = "QuickRegister"})
%>
</p>
<%
}
else
{
%>
<p>................
My method looks like:
public static RedirectToResult(Controller controller, ...)
{
}
when I do:
controller.
I don't see RedirectToAction, how come?
I get RedirectToAction from within the controller's action, but not when I pass the controller as a parameter to another classes method.
I have a controller method that returns a jSON object and in one calling situation, it works and in another calling situation, it does not work. When the URL in my browser is this:
http://localhost:65247/Client -- it works.
But, when my url looks like this:
http://localhost:65247/Client/UserAdmin?id=6 -- it DOES NOT work
In a nutshell, clients have users. From within the client, I wish to work on a specific user (this is the UserAdmin view). In this case, the client id is 6. From within the UserAdmin view that was launched with Id=6, I then wish to select a user from a dropdown. The idea was to use javascript and $.getJSON to fetch data for the specific user so as not to have to refresh the entire page. I use this approach in other parts of the app. The only difference I can see is with the URL in the browser. It would appear the presence of parameters via the '?' is futzing things up a bit.
In MVC2 does every single controller method have to map to a DIFFERENT view?Or can I make two methods map to the same view?
View 3 RepliesI 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 RepliesI've got an .aspx page with this in it:
<%@ Import Namespace="System.Web.Mvc" %>
<%= AssetController.ScriptTag("/js/Community/CommunityWizard.js")%>
And I have an AssetController class:
Imports System.Web.Mvc
Public Class AssetController
Inherits Controller
Public Shared Function ScriptTag(ByVal src As String) As String
Return String.Format(
"<script type='text/javascript' src='/js.mvc?src={0}&{1}'></script>",
System.Web.HttpContext.Current.Server.UrlEncode(src),
New BuildVersion().ToString()
)
End Function
End Class
The project has a reference added to the 3.0.0.0 version of System.Web.Mvc assembly. When I try to view the page in a browser, I get a HTTP 500 with this message:
BC30007: Reference required to
assembly 'System.Web.Mvc,
Version=3.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35'
containing the base class
'System.Web.Mvc.Controller'. Add one to your project.
What gives? I don't understand why I can use this controller everywhere in our ASP.NET Forms/MVC hybrid application, but not in a view. EDIT: In fact, when I type <% System.Web. into the .aspx view, Mvc doesn't even appear in Intellisense!
I am using the Nhibernate with MVC. In the controller i am getting the model from the HttpSession. How can i set the model from controller Unit testing method.
View 1 RepliesIs it possible to retrieve the URL of a 3rd party webservice calling my controller method?
Things like Request.Current.Url refer to my own URL (/someController/someAction/).
The 3rd party webservice is sending HTTP POST data to my /someController/someAction and I wish to send back a HTTP POST message to the caller of the method, the 3rd party webservice, without using
return Content["some response"] which will force me to exit the method. Since the answer is plain text I would like to send it using HTTP Post.
What I actually try to do is respond to the calling webservice without exiting my method (return Content() will exit) so I can call other methods to process the data send to me by the webservice. I want to first tell the webservice I received their stuff and than process, in this way when a processing error occurs the webservice at least will not resend old data. Is there another way to do this than building your own HTTP post?
I have a form with a drop down list. I want to pass the value of the selected item and a hidden field called stidentid to a controller action that would check my database to see if records for that id and semester exist and return the view with the appropriate values filled in. I'm not really familliar with Javascript or Jquery so I tried this:
[Code]....
}).change();
however nothing happens when I select anything from the semester list not even a crash. What am I doing wrong?
I'm using MVC2.
I added routher for url: "autors/year-range/1928/page2"
routes.MapRoute("AuthorsPopular",
"authors/{action}/{param}/{page}",
[code]...
Since Year-Range is invalid method name.
Why will not fill View page of this controller method
public ActionResult Person()
{
testEntities6 testPersons = new testEntities6();[code].....
I am trying to extend controller with extension method which redirects to 404 page.
[Code]....
However, controller.View() method is internal and can't be called outside class methods.
I'm trying to write a controller method that returns an ActionResult.
In this method, i would like to:
1. call an HTML helper method
2. Capture and store the HTML helper's rendered HTML in a string
3. Return the method with the rendered HTML wrapped as a JSON
How do i call the Html Helper method from my controller method? Simply using the static class HtmlHelper does not work.
I have ascx partial view with html-layout like that
<%=Html.ActionLink<PersonController>(x => x.Publications(param1, param2, ... )) %>
My ascx is pretty big & I'd like to reuse it, changing controller/method in Html.ActionLink with another controller/method. Method of another controller has the same signature as PersonController.Publications. Whats best way how to make controller/method configurable for my layout.
I have an editable table in my view.
how can i accept the whole table in a controller action method?
what parameter should i gave to accept the whole table