MVC :: Pass Multiple Parameters In Html.actionlink?

Oct 09, 2010 09:10 PM

how can i pass multiple parameters in html.actionlink?


MVC :: Pass Multiple Paramater To Html.ActionLink?

Nov 12, 2009 08:01 AM

I am new to MVC. is there any way to pass Multiple paramater to Html.ActionLink .

View 3 Replies View Related

MVC :: Sending Parameters With Html.ActionLink?

Feb 11, 2011 08:40 AM

How can we send these parameters in Html.ActionLink statement?(one by one not all of them)

1- selected value of a DropDownList.

2- Form collection.

3- our Model.

View 5 Replies View Related

MVC :: Html.ActionLink / Create Query String Parameters In The Link?

Aug 20, 2009 02:03 PM

I am using MVC to access custom reports which may be drill down reports. I use the convention of Controller/Action "Reports/Open/id/level"

Ok so we hit the top level report "including my query string parameters which could be different for each report Example /Reports/Open/1?CostCentreId=10000&year=2010

I want to open up my drill down, I am binding the data to display using a class , so far so good.

My sub report gets the query string parameters because I stored them in ViewData. In order to get back to the Top level report I have to create query string parameters in the link. How do I do this with an action link?

View 4 Replies View Related

Html.actionlink Doesn't Pass Parameter To Controller Action

May 12 10 at 14:02

m having problem in passing parameter to controller action, i have done the following

Url.Action("SchoolDetails","School",new{id=item.SchoolId}) and my controller action follows

public ActionResult SchoolDetails(string schoolId,_ASI_School schoolDetail)
schoolDetail = SchoolRepository.GetSchoolById(schoolId);
return View(schoolDetail);

i dn't know why the schoolId above in action is getting null..

View 1 Replies View Related

C# - Pass Model Values As Javascript Function Parameters From Inside Mvc Html Helper Such A Html.Radio?

Jul 20 10 at 16:38

I think I need to drop in some escape characters, but I'm not quite sure where. Here is the javascript function I'm attempting to call:

function setData(associateValue, reviewDateValue) {
var associate = document.getElementById("Associate");
var reviewDate = document.getElementById("ReviewDate");
associate.value = associateValue;
reviewDate.value = reviewDateValue;

Here is the asp .net mvc line where I'm attempting to create a Radio button with a click event that calls the above function and passes data from the model as javascript parameter values.

<%= Html.RadioButton("Selected", item.Selected, new { onClick="setData('<%=item.Associate%>','<%=item.ReviewDate%>' )" } )%>

The above throws a bunch of compile issues and doesn't work. A call such as the following does call the javascript, but doesn't get the data from the model.

<%= Html.RadioButton("Selected", item.Selected, new { onClick="setData('item.Associate','item.ReviewDate' )" } )%>
<%= Html.RadioButton("Selected", item.Selected, new { onClick="setData('item.Associate','item.ReviewDate' )" } )%>
<% String functionCall = String.Format("setData('{0}','{1}')", Html.Encode(item.Associate), Html.Encode(item.ReviewDate )) ; %>
<%= Html.RadioButton("Selected", item.Selected, new { onClick=functionCall } )%>

View 2 Replies View Related

AJAX :: Pass Multiple Parameters From C# To JavaScript?

Jan 26, 2010 01:45 PM

i want to update my page from database every 20 for that i want to pass multiple data fields from server to Client using AJAX.. what can i use for that except using xml?

View 3 Replies View Related

Javascript - Pass Multiple Parameters To OnSuccess Method Of PageMethod?

Dec 9 10 at 12:34

I'm calling PageMethod "SameMethod" from javascript method "caller" so that I can get some values from DB. After I get values, control is continuing in "onSuccess" method. Problem is that I need to use some variable values ("importantValue") from javascript method "caller" in "onSuccess" method.

function caller(){
var importantValue = 1984;
PageMethod.SomeMethod(param1,..., onSuccess, onFailure)

onSuccess method should be something like this:

function onSuccess(pageMethodReturnValue, importantValue ){

Is it possible and, if it is, how to pass multiple parameters (besides return values of page method) to "onSuccess" method of PageMethod?

View 2 Replies View Related

ListBox - Pass Multiple Selected Values To Stored Procedure As Parameters

Nov 06, 2009 05:41 PM

I have a drop down list control. But now it is required to use ListBox control that displays number of ListItems. End user can select more than one ListItem. I am using Stored procedure to query the database and return results.


Now it is required to pass all the Selected List Items to stored procedure. I like to know the best approach to meet this requirement.

This is what i have at the moment:-


View 6 Replies View Related

AJAX :: Pass Multiple Parameters To Wcf Service Using Auto Complete Extender?

Feb 10, 2011 08:06 AM

I have a wcf service and method returns a string array as follows


How can I pass required multiple parametes (name, cuo, year ) to this service using ajax AutoCompleteExtender.

If I could not use autocopleteExtender what would be the best way to achieve this.

View 1 Replies View Related

Forms Data Controls :: Pass Multiple Parameters In A HyperLinkField Field?

Aug 15, 2010 06:57 PM

I am creating a grid with a code behind and in the hyper link column I would like to pass some parameters before passing users to a new page. If I just use one parameter, the CustomerID in the dataNavigateUrlFields and dataTextField then the

linkField.DataNavigateUrlFormatString = @"/details.aspx?Customerid={0}";

statment works fine.

Now my requirement is to pass multiple parameters and when I tried the following it gave a

'A field or property with the name 'System.String[]' was not found on the selected data source.'

Here is the code snippet:

HyperLinkField linkField = new HyperLinkField();
string[] dataNavigateUrlFields = { "CustomerID", "CompanyName", "FirstName" };
linkField.DataNavigateUrlFields = dataNavigateUrlFields;
string[] dataTextField = { "CustomerID", "CompanyName", "FirstName" };
linkField.DataTextField = dataTextField.ToString();
linkField.DataTextField = "CustomerID";
linkField.HeaderText = "Customer ID";
linkField.DataNavigateUrlFormatString = @"/details.aspx?Customerid={0}&CompanyName={1}&FirstName={2}";

Does some one know how pass the multiple parameters via the hyperlinkfield in C#?

View 3 Replies View Related

MVC :: ActionLink Return An Url With Parameters In Querystring?

Jan 17, 2010 01:47 PM

I try to have an URL like this /Forum/Index/2 for url I have a route {controller}/{action}/{page} in my global.asax

If i test the above url with the Route Debugger it corresponds to the above route ( and some other but this is the fist one in the list ) but if I create an url with the ActionLink

( like this : [Code]....

this methode return me this URL /Forum/Index?page=2 Is there a way to a have an url with nothing in querystring with the ActionLink methode ? Gauthier

View 10 Replies View Related

Html.ActionLink() Gives An Empty Link When Use It Inside Html.RenderAction()?

Feb 18 10 at 19:47

I have a Microsoft MVC project with an action "Foo" whose view ("Foo.aspx") contains the lines:

<%= Html.ActionLink("mylinktext1", "bar") %>
<%= Html.ActionLink<MyController>(x => x.Bar(), "mylinktext2") %>

When I hit this from a web browser or load it from an AJAX call, it properly returns:

<a href="/bar">mylinktext1</a>
<a href="/Bar">mylinktext2</a>

But when I call the action from another view like this:

<% Html.RenderAction<MyController>(x => x.Foo()); %>

Then the links are rendered without targets.

<a href="">mylinktext1</a>
<a href="">mylinktext2</a>

Why would this be happening, and how do I work around it?

View 1 Replies View Related

How To Pass Parameters To An Action Using Html.Action() In MVC?

Jun 30 10 at 15:00

I've been using Html.Action("ActionName", "ControllerName") to invoke child actions across controllers without needing to have the view in ViewsShared. This has been working great for displaying things like session or cookie information.

Instead of just accessing cookies, I would like to pass additional parameters to Html.Action("ActionName", "ControllerName") so the action can execute different code based on the the data passed to the original view.

Should I be using a different method to pass parameters to a child action in a different controller?

View 1 Replies View Related

MVC :: How To Pass Textbox Value To Action Via ActionLink

Jun 24, 2010 07:06 PM

Having a brain fart again - i just wanna pass the contents of a TextBox to a Controller Action via an ActionLink - and i cant figure out how

Heres my View


My Controller:


but name is always null - how can i pass the current value in the textbox? ViewData directionary doesnt seem to work either

PS. Id love to pass the entire model from the View -> Controller - but it complains about not having a parameterless constructor (which i do)

View 5 Replies View Related

Pass Dictionary Of RouteValues To ActionLink?

Mar 13 10 at 19:28

Getting to grips with ASP.NET MVC. So far, so good, but this one is a little nuts. I have a view model that contains a dictionary of attributes for a hyperlink, used like this:

menu = model variable Html.ActionLink(Html.Encode(menu.Name), Html.Encode(menu.Action), Html.Encode(menu.Controller), menu.Attributes, null) The problem is the position of "menu.Attributes" expects an object in the form:

new { Name = "Fred", Age=24 }
From what I can tell, this anonymous object is actually converted to a dictionary via reflection anyway BUT you can't pass a dictionary to it in the first place!!!

The Html generated for the link simply shows the dictionary type. How on earth do I get round this? The whole point is that its general and the controller can have set the menu.Attributes previously....

Based on a post below I tried the following:

Html.ActionLink(Html.Encode(menu.Name), Html.Encode(menu.Action), Html.Encode(menu.Controller), new RouteValueDictionary(menu.Attributes), new Dictionary<string,object>())

but this still doesn't work (I guess the code internally calls the generic method that takes objects?). The above (and my original solution of passing a dictionary to the 4th paramater produces a HTML similar to this:[URL] i.e. it's using reflection and working things out completely wrong...

View 4 Replies View Related

MVC :: Cannot Pass Model To Action Via ActionLink?

Jun 04, 2010 04:11 PM

I'm trying to implement paging in my app, so i need to know what page the user wants to click on, as well as pass the model (for some fields)I'm able to pass the desired page, just not the model (for the search criteria)here is my view:


Heres my Controller Action


My ViewModel SearchResults has a string property "Search". When i do it this way searchModel == null in the NextPage Action.

View 2 Replies View Related

MVC :: How To Reference Html.ActionLink In A Custom Html

Jul 24, 2009 11:40 AM

I know you can do this System.Web.Mvc.Html.LinkExtensions.ActionLink()

but how about the 10 overloaded methods? How do I account for them in my custom Html helper. Like is there away I can just pass in a whole actionLInk object or something?

Like I want my end result to be:

<a href="linkHere><span>Hello</span></a>

of course in the anchor tag I might have stuff like the Id and everything else.

View 4 Replies View Related

Javascript - Html.ActionLink In Html.TreeView?

Dec 18 10 at 18:41

Im using the HTML.TreeView to render my code structure like this :
<%= Html.TreeView("CategoryTree",
l => l.ChildList,
l => l.Name + " / <a id="treeLnk" + l.Id + "" href="JavaScript: OpenAddDialog('" + l.Name + "', " + l.Id + ") " title="Lägg till" >Lägg till</a>" +
" / <a id="treeLnk" + l.Id + "" href="JavaScript: OpenChangeNameDialog('" + l.Name + "', " + l.Id + ") " title="Ändra namn" >Ändra namn</a>" +
" / <a id="treeLnk" + l.Id + "" href="JavaScript: OpenDeleteDialog('" + l.Name + "', " + l.Id + ") " title="Tabort" >Tabort</a>") %>

This work fine, but now I need to include a action that redirects to another controlleraction.

I have tried to ad a Html.ActionLink but this does not work?

View 1 Replies View Related

SQL Server :: What If Multiple Output Parameters And Input Parameters And Also Want A Select Table

Feb 16, 2011 04:48 PM


When I want to get the output values its okay but I also want returning a table as a result data.But Datareader has no it possible if I want a returning query result and multiple output values togather ?I wrote a test above.I can get output values as sqlparameters. But Datareader attached to a Gridview is empty.can you detect whats wrong here and it doesnt return a query result.So stored procedure is not standart or ı am doing something wrong.this doesnt raise any exception.but not returning any data.


View 8 Replies View Related

How To Pass JavaScript Function As A Parameter In The Route Values Of Ajax Actionlink

Apr 20 10 at 6:51

I need to pass javascript function as a parameter value to the ajax actionlink in mvc app. how can we achieve this?

View 1 Replies View Related

MVC :: Pass Parameter To Javascript Function From OnSuccess Event In Ajax.ActionLink?

Apr 27, 2009 06:50 AM

When I use:

new AjaxOptions { UpdateTargetId = "VoteCount" + indx, OnSuccess = "AnimateVoteMessage" }

everything works fine...but I am trying to animate items in a list, with automatically assigned ID's. Since I want each of these to be addressable from my javascript, I believe I need to pass a parameter to my javascript. But when I use:

new AjaxOptions { UpdateTargetId = "VoteCount" + indx, OnSuccess = "AnimateVoteMessage(2)" }

I get an " Sys.ArgumentUndefinedException: Value cannot be undefined." exception. Well I get that when using the debug versions of MicrosoftMvcAjax.js. When using the compressed version I get a "Microsoft JScript runtime error: 'b' is null or not an object" So my question is, can I pass a parameter to my javascript function using the OnSuccess event for a ActionLink? Is this the right approach? How else am I going to have one javascript function have the ability to be run on 10 items (in my case the IDs of multiple DIVs) on my page?

View 6 Replies View Related

C# - How To Html.ActionLink And HTML As Parameter

Jul 31 10 at 18:13

Html.ActionLink("<span class="title">Retry</span><span class="arrow"></span>", "Login", "User")

If I execute above code in ASP.Net MVC 2, I get the following output on my screen:

How do I disable the escaping of the code, so my span is within the ActionLink, and not displayed as output?

I know this is expected behavior, to keep it safe, but I want it to interpret the HTML code I pass as a parameter.

View 4 Replies View Related

Using Html.ActionLink But Not Html Encoding?

Oct 19 10 at 15:06

I wish to return the following output

<a href="#"><img src="/images/icons/tick.png" alt="" />More info</a>

If i do the following the content is html encoded.
<%= Html.ActionLink("<img src='/images/icons/tick.png' />More info", "OrderRegion", "Campaign", new {id = Model.Campaign.Id}, null) %>

How can i disable the html encoding?

View 2 Replies View Related

How To Use Html.ActionLink()

Dec 18 10 at 17:43

I'm pretty new to ASP.Net / MVC 2. Can anyone explain how to use the Html.ActionLink thing? I understand that the first parameter is the displayed text, but for the second one, what is the action name?

View 1 Replies View Related

MVC :: How To Use Html.ActionLink

Jul 22, 2009 03:48 PM

I tried to use Html.ActionLink<T> like:

<%=Html.ActionLink<MyCOntrroller>(c=> c.MyACtion(, "html"), employee.Name) %>

But VS2008 give me error. I am not sure if this is still available for MVC 1.0 or I made some mistake?

View 4 Replies View Related

MVC :: Url.Action Vs Html.ActionLink

Dec 06, 2009 07:31 PM

Is there any advantage or disadvantage in using either one over the other?

View 2 Replies View Related

Use An Asp:Button Like An Html.ActionLink?

Jul 4 10 at 3:38

I have an ActionLink: <%: Html.ActionLink("MyAction", "MyAction") %> I would like to use a button instead. Something like this: <asp:Button ID="Button1" runat="server" Text="MyAction" /> What do I need to do to make clicking the button perform the same action as clicking the ActionLink?

View 1 Replies View Related

MVC :: HTML.ActionLink() To Post?

Sep 15, 2009 08:25 PM

I have a lot of hidden values, but the form will be posted using the actionlink.

eg : <%= Html.ActionLink ("Create New Group", "CreateNewGroup",)%>

How do I post all the hidden variable to the form ? Is there anything linkbutton in the MVC ?

View 1 Replies View Related

C# - Html ActionLink Isn't Displaying?

Jan 5 at 20:39

I'm showing a small table with a list of usernames, and I want an ActionLink next to each username to Edit the user on another page.


The usernames display correctly, just the link doesn't show up. I'm not sure why it wouldn't throw an error instead.What am I missing here?

View 2 Replies View Related

MVC :: Html.ActionLink Method ?

Sep 30, 2009 05:31 PM

I am new to ASP.Net MVC framwork. I have followed Scott Gu's tutorial to learn it.My question is ScottGu mentions that Html.ActionLink("Catagory", new{action="List", id ="3"} in the aspx page. But while I put this in the ASPX page it is not allowing this signature it is allowing only


View 2 Replies View Related

MVC :: Html.ActionLink - Not Showing Correct URL

Jan 25, 2011 12:10 AM

Over the past 3 days I've been trying to do everything in MVC. I want to learn this awesome technology.

I have just faced a problem with Html.ActionLink and I can't figure it out ! Here is what I have in my Home Index View:


View 8 Replies View Related

MVC :: Url.RouteUrl Vs Html.ActionLink Vs Url.Content

Jun 28, 2010 04:26 PM

I was reading the ASP.NET MVC Best Practices article by Rashid, and got stuck in his description of creating UrlHelper extensions. Doing this is easy enough, and I've adopted the practice into all of my projects. I noticed, however, that Rashid used Url.Content to generate the url for the home page, and Url.RouteUrl for all the other urls. Why is this? What is the difference between the two?

The link to the blog post is here:

I've used Html.ActionLink in my Views, but I'm wondering what difference it would be if I used Url.RouteUrl instead. Does anyone have a good grasp of what makes these helpers different, and where they are best used?

View 1 Replies View Related

MVC :: ASCX Html.ActionLink Not Showing

Aug 12, 2010 09:08 AM

I assume this link is correct

Html.ActionLink("Edit", "Edit" , new {Controller = "Item", id = item.Product_GUID});

the books tell me things i have read etc.i should render html as <a href="/Edit/Item?id=foo>Edit</a>

I am sending them to "another controller" to edit the item...

But this is not rendering the hyperlink in my browser, UGH....

this code is in a ascx page so i can call it with partialaction.

All i can think is that its not working because its 5am and i have been up since 9am yesterday..

View 5 Replies View Related

MVC :: Passing A String To Html.ActionLink?

Dec 23, 2009 09:33 AM

I have a page where quick links are dynamically added from the database, when the user clicks on one of these links I want to go away and do a search based on the text of the quick link.

For example
Meat etc

It is straightforward to use Html.ActionLink with an ID, however I need to use the text of the link as this will not match to an ID in a database, reather it will match the column of a row in the database.

So my database may have

ItemID - 266
ItemName - Strawberry
ItemCategory - Fruit

The quick links I will display will correspond to data in ItemCategory, therefore the Search Action I redirect to needs to know the text of the quick link in order to go to the database and do a search.

how I would so something like

<%= Html.ActionLink(cattegoryName,
"Search", new { category=categoryName})%>

Would I need to change the global.asax to handle a cagegoryName field and could it be a string rather than an integer

View 1 Replies View Related

MVC :: Two Html.ActionLink In A Column Using Webgrid?

Feb 15, 2011 04:59 AM

I m facing a problem in WegGrid MVC 3 razor, my code:


How to merge the Edit & Delete links into the same column (Actions)??

i tried to create two (item) in same column, but i get error message.

View 7 Replies View Related

Stuff Viewmodel Into Html.actionlink?

May 7 10 at 19:46

Is there a way to stuff my ViewModel into an Ajax.ActionLink? edit I'd like to take my 5 search fields on my page which are bind to a view model and send it along my .ActionLink as my object value parameter.

View 2 Replies View Related

Insert Image In Html.actionlink - Mvc?

Sep 8 10 at 13:02

how to insert image in html.actionlink - mvc? i did it so, but it doesnt works.

<a href="<%= Html.ActionLink("search", "Search", new { searchText = "txtSearch" }, null); %>">
<img alt="searchPage" style="vertical-align: middle;" height="17px"
src="../../Stylesheets/search.PNG" title="search" />

View 2 Replies View Related

MVC 3 RC Html.Actionlink Not Generating Link

Dec 6 10 at 14:05

I have a route (the first one listed) which looks like this:

"TopicRoute", // Route name
"forums/{forumSlug}/{topicSlug}", // URL with parameters
new { controller = "Forums", action = "Topic"} // Parameter defaults

I can browse to: /forums/my-forum/my-topic and the page loads fine. Yet I have a Html.ActionLink that looks like: @Html.ActionLink(item.Title, "Topic", new { forumSlug ="my-forum", topicSlug = "my-topic" }) And it won't generate the correct link syntax for me? It generates: <a href="">My Topic</a>

View 1 Replies View Related

Using CSS In ActionLink Inside HTML.Partial

Mar 22 at 16:13

I'm having problems getting my CSS class to style an actionlink inside a html.partial. In building my test site, I've used the template beginning from ASP.NET and the standard login portion. My Index page works fine as the _Layout.cshtml does reference my css page. In _LogOnPartial, I have the following listed (there is more but this is what's important I believe):

else {
<ul style="display:inline;">;
<li style="list-style:none; display:inline;">
@Html.ActionLink("Sign In", "LogOn", "Account", null, new { @class = "signin" })

My CSS for "signin" is:

.signin {
text-decoration: none;
font-family: Helvetica, Arial, sans-serif;
font-weight: bold;
color: White;

When I look at the source for the page after debugging, it shows:

<a class="signin" href="/Account/LogOn">Sign In</a>

That looks right but it's not showing it correctly. The font isn't Helvetica and it is underlined and not white. I don't reference the css sheet in the LogOnPartial but I didn't think I'd have too.

View 2 Replies View Related

Copyrights 2005-14, All rights reserved