.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Post New Web Links


Posted By:      Posted Date: September 28, 2010    Points: 0   Category :ASP.Net

Can somebody please help me out?
I'm getting the error RenderAction.
This is the code I wrote on View

<% Html.RenderAction("ActionUserControl", "OfferController"); %>

and Controller,

        [OutputCache(Duration = 60, VaryByParam = "None")]
        public ActionResult PartialList()

            return View();


View Complete Post

More Related Resource Links

Conditional styles for selected Html.ActionLink


Hi, I am trying to add an item selected class to an Html.ActionLink, I am very new to MVC so its all a bit confusing.

So far i have each of my ActionLinks lookins like this

<li><%: Html.ActionLink("Home", "Index", "Home", new { @class = ViewData["current"] == "Home" ? "selected" : "" })%></li>

And in the controller i have

public ActionResult Index() {
            ViewData.Add("current", "Home");
            return View();

Can any one tell where i am going wrong because the links now fail to respond, basically it isn't checking the condition == Home and if it is then its failing because it doesn't get to the controller.

Any ideas would be appreciated


Asp.net MVC: How to call javascript function in Html.ActionLink

When I edit single recored in page, I use checkbox to get a selected row not every row with an actionlink element, but it seemed I cant make this way happen through calling javascript code(function GetSelectedRow() should return an id). Could anyone have a nice idea?<head runat="server"> <title>Index</title> <script type="text/javascript" language="javascript"> function GetSelectedRow() { var a = 0; var chkBoxes = document.getElementsByName("chkSelect"); var count = chkBoxes.length; for (var i = 0; i < count; i++) { if (chkBoxes[i].checked == true) a = chkBoxes[i].primaryKeyID; } return a; } </script> </head> <body> <div> <span style="width:20%"> <%: Html.ActionLink("Add", "Create")%> </span> <span> <%: Html.ActionLink("Edit", "Edit", new { id = GetSelectedRow()) %> </span> <span> <%: Html.ActionLink("Detial", "Details", new { id = GetSelectedRow() })%> </span> <span> <%: Html.ActionLink("Delete", "Delete", new { i

Html.ActionLink displayes unwanted virtual directory routing

My hosting provider has ASP.NET 3.5 and I'm using MVC 2.0. I have two domains on my account, http://www.domain1.com, and http://www.domain2.com, each has it's own virtual directory off of the root: / /domainone /domaintwo   Their routing commands for their httpd.ini rerouts http://www.domain1.com to http://www.domain1.com/domainone   If I type in the address bar http://www.domain1/Home/About, it works properly. The Problem My website links created using Html.ActionLink add the virtual directory. If you mouse over the About link in your standard MVC2.0 webapp, it displays as follows: http://www.domain1.com/domainone/Home/AboutAll of my testing and setup on my development machine doesn't have this virtual directory, and in the past my webhost didn't have this issue in the path. But since the move to their 'new' shared hosting platform, this is now what I'm having to deal with. How do I setup my ASP.NET MVC 2.0 web application to remove the unwanted virtual directory name from the path in my ActionLink controls? For example, when I mouse over the About link, I want the path to be http://www.domain1/Home/About ..or how can I add a new route handler to strip the virtual directory path from http://www.domain1/domainone/Home/About.   When I mouse over the Log On button on my logon page, the partial url domainone/Account/Lo

VWD2010, MVC2, Html.ActionLink and Application[]



This is my code:

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
    if (Request.IsAuthenticated) {
        <%:Application["Welcome"] %> <b><%: Page.User.Identity.Name %></b>!
        [ <%: Html.ActionLink(Application["LogOut"].ToString, "LogOff", "Account") %> ]
    else {
        [ <%: Html.ActionLink(Application["LogIn"].ToString, "LogOn", "Account") %> ]


What I want to do is pretty simple, I set appropriate values in the application array at the global.asax level and would then want to see those values be written in place of the default ones. That obviously does not happen or I wouldn't be writing here :-P


It gives out an error saying it doesn't find an correct overload for the method ActionLink(or something along these lines anyway).

Clearly, that's wrong :-P since I would expect it to display m

How to get the link portion of an ActionLink



I am developing a page that has an image element that has its source set to an action on a controller (e.g., "/controller/action". The problem that I am having is that I don't see a built in way to generate a URL (i.e., like an ActionLink's URL) without manually constructing one. At the moment, I am manually constructing the URL, but I want to move away from this. Before I write my own helper method, I thought I would check to see if one it already available. Does such a method exist?

BTW, this is using MVC2, VS 2010.


If-Else condition for ActionLink in Html Extension


In my code, I'm trying to write "if" condition in HTML.Helper instead of view.
Can you please tell me what mistake i'm doing?

Code on Controller

public static string IsSetup(this HtmlHelper helper, AModel aModel) 
string actionLink = string.Empty; 

 if (aModel.IsSetup) 
 { actionLink = "Html.ActionLink(\"" + "Continue for Setup\"" + "," + "\"Setup\"" + "," + "\"SetupController\") "; return actionLink; } 

 { actionLink = "Html.ActionLink(\"" + "Continue for Index\"" + "," + "\"Index\"" + "," + "\"SetupController\") "; 

 return actionLink; 


Code on View
        Please click to
        <%= Html.IsSetup(Model)%>
  // I'm expecting, <%= Html.ActionLink("Continue for Setup", "Setup", "SetupController") %>
  // but it renders as a TEXT like,  Please click to <%= Html.ActionLink("Continue for Setup", "Setup", "SetupController") %>

Seeking Routing help. Problem with ActionLink.

 I have 2 action links:
<%: Html.ActionLink("Home", "Index", new { area = "", controller = "Home" })%>
<%: Html.ActionLink("About", "About", new { area = "", controller = "Home" })%>

They are rendering as: <a href="/">Home</a> <a href="//Home/About">About</a>

Which is the problem. The // is causing the browser to go to hxxp://Home/About Other ActionLinks are working fine such as.

<%= Html.ActionLink("Log In", "LogOn", new { area = "Authenticate", controller = "Main" })%>
<%= Html.ActionLink("Register", "Register", new { area = "Authenticate", controller = "Main" })%>

They are rendering as: <a href="/Authenticate">Log In</a> <a href="/Authenticate/Register">

using dynamic text with HTML.Actionlink


Hello there my second post of the day this is becoming a habbit LOL  :)

as part of my web app i have a series of buttons created using HtmlActionlink


<%=Html.ActionLink("Swap User", "Index","Home")%></td>   

However my buttons need to be translated into difrent languages depending on the    country the user is in 

Im translating the button lable text fine in my controller and passing it into the view , but now im alittle stumped over syntax

Id like to replace "Swap User" above with 

Add textbox and change ActionLink to use textbox input


How do I add a textbox for user input in the view and then change the link below to user the user input instead of the hard coded ID?

<%= Html.ActionLink("click me", "Index", new { id = 10057 } ) %>



I am using Ajax.Actionlink.

I have object(SearchModel) which inside contain one more object(OperatorValue) when I am using below action link.my classID is getting set but my Context is not getting set to my action.



<%=Ajax.ActionLink("Material", "SearchForm", "Search", new SearchModel { ClassID = "BIDDING MATERIAL", Context = new OperatorValue{Value="ABC", Operator = "=" } }, new AjaxOptions { UpdateTargetId = "Search", HttpMethod = "Get" })%> 



Query1:Context pararmeter is not getting set.Can anyone let me know the solution for this problem?

Query2:When I click on list item "Material",my action controller is not getting called...It is getting called for the first time.


MVC 2, ajax.actionlink and updating the link text onSuccess



I have a scenario where the ajax actionlink text is 'Apply'..On clicking this and calling an action successfully, i want the link to be disabled and to be changed to 'Application successful'.

How can i do this?


multiple parameters in html.actionlink



how can i pass multiple parameters in html.actionlink?


Ajax.ActionLink problem


<%= Ajax.ActionLink(
                           "Varazdinska zupanija",
                           new { id = "105" },
                           new AjaxOptions { UpdateTargetId = "MeteoDIV" }

Display html.actionlink through c


Hello guys,

I am noob and am trying to display Html.Actionlink through controller(MVC). Here is the example what am trying to do...

public string test(){

     string testString = "<%: html.ActionLink('click', 'test', new AjaxOptions() { UpdateTargetId = 'test' }) %>";

     return testString;


i want to display testString in view. but am not getting the actionlink in view..i can display anchors which is given below:-

public string test(){

     string testString = "<a href ="test"> click here</a>";

     return testString;


Hope reader is understanding what am trying to say...

any help would be appreciated.



setting css class on actionlink



i'm trying to set different css class on an action link, it's very easy with a regular one, but i'm strugeling with this one:

<%= Html.ActionLink("En", "ChangeCulture", "Home", new { lang = (int)GOaHEAD.Helpers.Culture.en, returnUrl = this.Request.RawUrl }, new { @class = ViewData["culture"] == "en" ? "EnLinkselected" : "EnLink", @title = "English" })%>

i figured out already that using the viewdata["culture"] will not work, since i didn't set a culture in the controler. but i do get the /en/ in the link itself.

the question is how do i do it? i have a localization helper, but can i do it there ?

Detecting Data Returned from an Ajax.ActionLink Call



How can I detect if an Ajax.ActionLink call returned any data?  See below:

	<div id="moreResults">
	<script type="text/javascript">
		var index = 1;
		function MoreResultsComplete() {
			// ***** How do I detect if data awas returned here? *****
			$(this).attr('href', '/Controller/MoreResults?index=' + ++index);
	<img class="loading" src="/content/images/loading.gif" alt="Loading results..." />
	<%: Ajax.ActionLink("More Results", "MoreResults", new { index = 1 }, new AjaxOptions() { LoadingElementId="loading", UpdateTargetId = "moreResults", InsertionMode = InsertionMode.InsertAfter, OnSuccess = "MoreResultsComplete" }, new { @id = "moreResultsLink" })%>


Passing values with ActionLink


I am new to MVC but here is my issue,  I have a logon page with a checkbox to display a html helper Textbox.  The textbox is for a user to enter there email so they can reset their password.  Once the email is entered.  The user clicks on a Actionlink which takes them to the Controller.  I need the actionlink to pass the email address entered to the Controller. 

 I tried using Html.Text("txtEmail") but to no avail.  Also tried to pass it along the actionlink by using   actionlink("reset password","Password", "Pass", new { id = "txtEmail" }).  But it didn't work either.  Any help is appreciated.

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend