MVC :: Add Parameter Dynamically In Jquery & Passed It To Controller?
Sep 10, 2010
code is like -
[Code]....
so in this line i am passing "ss".but in my controller i didnot get the value in a parameter variable, instead i am getting ss as parameter, not the selected ids.how can i do that.
I have a requirement whereby I need to be able to change the controller being used based upon a parameter. I am creating an application that needs to be dynamic enough to be able to change controllers on the fly. Let me explain further;
When the application starts a dictionary of custom controller names is loaded with a controller name as the key and a custom controller name as the value. This will be help in the application scope.
When a request is made I need to access the requested controller name, use that name and check to see if it matches a key in my controller dictionary and if so, replace the requested controller name with the custom controller name from the dictionary.
example;
My dictionary will contain data as follows Key: 'Home', Value: 'Home_IN' Key: 'Customer', Value: 'Customer_BE'
Now, the following request is made 'User/Edit/1'. Does the controller name exist in the dictionary? No, continue with original request.
Now, the following request is made 'Home/Details/2'. Does the controller name exist in the dictionary? Yes, replace the original controller name 'Home' withe custom controller name 'Home_IN' so changing the requested URL to be 'Home_IN/Details/2'.
Does this make sense?
My problem here is knowing exactly where in the request cycle I need to do this?
I am assuming I need to create my own custom controller factory?
I have a simple model where a Person has Gifts. I have a view which is a list of Gifts belonging to one Person.
My problem is with the Create action for a new Gift. I want it to default to the PersonID that we are already viewing the list of Gifts for. I tried simply passing the last PersonID (they are all the same)
Html.ActionLink("Create New", "Create", new { id = Model.Last().PersonID }) which works fine if there is already at least one Gift for that person but if this is the first Gift I don't have a value.
My Gift List controller knows the PersonID I want to pass but the view doesn't.
How do I pass this PersonID from my Gift List controller to my Gift Create controller via the Gift List view? Or is there a better way to do this?
I am trying to use the Slideshowexternder control with a contextKey that I've set from a query string. I set the contextKey in the default.aspx.vb Page_Load as I've read in other posts, but I am still getting an error:
The server method 'GetSlides' failed with the following error: System.InvalidOperationException -- Invalid webservice call, missing vaule for parameter: 'ContextKey'
I have a SQLDataSource control that is calling a database stored procedure, and passing quite a large number of paramaters, and the stored proc returns records that populates a gridview control. When I walk through the code behind to determine the values being passed, is there any way that I can see exactly how the parameters are being formated and passed to the stored proc?
Due to certain reasons, in our ASP.NET web application, it is not recommended to use Response.Redirect("something", True). It should be used with False for the endResponse parameter. We want to enforce this with a custom FxCop rule. I've managed to find the usages of Response.Redirect, but now I want to find the value of the endResponse argument. How can I do this?
We're using the following code:
[Code]....
I've used Introspector and thought the endResponse parameter was an integer behind the scenes, but I'm not so sure anymore. Anyway, there don't seem to be any booleans in the methodCall.Operands.
need to check the actual value of a parameter that's passed to a method?
Just to rule it out, I have tried using the AJAX Rating system to no success, so i've decided to develop my own (as useful as AJAX seems to be for some reason I've never got it working on my system). I'm using a Star Rating Widget I attained from [URL] and from there I've taken a demo (so that it is working) and started editing it accordingly to my needs.
What I am setting out to do convert the radio buttons to stars (done via jQuery and working correctly). The user selects their rating then clicks the the Submit Button. The C# in the Submit OnClick Event then accesses the database, using LINQ to SQL, taking the current 'NumberOfVotes' value and adds one to the number, storing in an int object ready to update. The current 'Rating' Value is then updated too, by adding the Value of the Radio button to the current Rate Value then divided by the number of votes (to create the average rating) 'This article has been rated 4.28/5 by 286 Voters.'
However, the value from the selected radio button isnt being passed through to the back end, as debug has shown, and as you will see in the code below. The jQuery does state a callback which i had initially commented out (due to errors being caused). I have since reassigned it as advised, with a small edit in it to call the btnSubmit control and thus its onclick Event. Im not sure on a resolution to this having tried the only advised suggestion fail. The result of which posts back the message which should appear if no value/star was selected ("You have not selected a rating!"). If I can somehow transfer the jQuery to the ASp:RadioList I would do so, as I think this would be better in terms of calling and processing the data. Being new to it, I have no idea. In addition, apologies if my coding appears scrappy or poor
C#: Csharp Code: protected void btnSubmit_Click(object sender, EventArgs e) { RatingSys rate = RatingSys.Get(1); int RateID = Convert.ToInt32(hdnRateID.Value); int CurrentRating = rate.Rating.Value; int RadioValue = 0; int NewRating = 0; int NumberOfVotes = 0; if (!radio1.Checked || !radio2.Checked || !radio3.Checked || !radio4.Checked || !radio5.Checked) { lblMessage.Text = "You have not selected a rating!"; return; }...................
I have the following scenario: my website displays articles (inputted by an admin. like a blog).So to view an article, the user is referred to Home/Articles/{article ID}.However, the user selects which article to view from within the Articles.aspx view itself, using a jsTree list.So I what I need to do is to be able to differentiate between two cases: the user is accessing a specific article, or he is simply trying to access the "main" articles page. I tried setting the "Articles" controller parameter as optional (int? id), but then I am having problems "using" the id value inside the controller.
I'm using a custom route to create the following URL (http://mysite/subscriber/12345) where 12345 is the subscriber number. I want it to run the ShowAll action in the Subscriber controller. My route is firing and using Phil's route debugger, when I pass in the above url, the route debugger shows ID as 12345.
My controller is accepting an int as subscriberID. When it fires, the controller throws the error "The parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Int32". Why does the route debugger show a value and the controller doesn't see it?
Here's my route (first one is the culprit)
routes.MapRoute( "SubscriberAll", "subscriber/{id}", new { controller = "Subscriber", action = "ShowAll", id=0 }, new { id = @"d+" } //confirm numeric ); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults );
I'm getting a null in the ShowAll action? Here is the action method signature:
I'm having trouble when removing a dynamically created control, cause, on page_load i'm creating a new controller so the control.count is not counting correctly.
Here's the code for removing a controller:
[Code]....
And if anyone is interested here's the whole code:
I can't get my Controler action method to get hit when I click 'Detail View' tab, or any tab for that matter However, I can get the action method to hit if I comment out 'return false;' in the javascript section but then my 'Selected' tab is not maintained.
UML and Patterns: An Introduction to Object-Oriented Analysis and Design and Iterative Development, that follows the UP(Unified Process). It uses a Grasp Controller pattern to interact with domain classes by some methods like NewSale(), AddNewItemToSale() and CloseSale. In windows form, I can instantiate a object of this class in the UI and then use its methods to perform the actions. This works well in Client apps, but when I use asp.net mvc, I cannot find a way to instantiate an object (one for each user) that was always visible for a Controller (MVC). I cannot insert as an attribute inside Controller because it always create a new one.
Iam trying to pass data from my controller, and put it into the variable in JS script. I have done it before and it worked perfectly, thats why this one puzzles me even more.
Here is my code of the controller:
[Code]....
In chrome I also get an error "Uncaught SyntaxError: Unexpected token ILLEGAL". I am pretty sure it is the same I use for my other project and that one works just great so I really dont know what is wrong.
I am using a jquery tab control with multiple tabs. I want to do some actions in my controller and depending on those actions i want to disable or enable the tabs.
I have asp.net mvc application. i want to configure the object in jquery and want to pass it to the the action of controller . where as in my script i am using this for configure data for the ajax call:
[Code]....
it does not calls to action in controller. i think here :
var json = $.toJSON(peform);
is not working as expect. is it need to add any js file to reference ? or mistake in syntax?
I am using asp.net mvc 1.0. In this I have to create an UI for modifying the profile of the user. Now this modfiy profile will contain jquery tabs. and each jqeury tab will show some results such as user's personel information, professional info, etc on seperate tabs. I also want to give user ability to modify the fields and save this modified data. I am just not getting any idea how to do that. I have searched on internet for various jquery examples. most of them are just showing data to user by creating some partial views. Also i am not getting exactly how this functionality can be achieved through ajax on click of button.
I have a controller method "SaveFile" that attempts to download a binary stream to client's PC using the FileContentResult. If I make the call as a post from the controller corresponding view everything works OK. I want to call the same controller method "SaveFile" from a jquery function via an .ajax call, when I do the function returns an error and the responseText is the contents of the file to be written. What would I have to do to get the same behavior from a jQuery function as if the MVC framework handled the call via the submit button? Or an alternate solution would be to determine how can I catch the browser's download dialog close event.