MVC :: Setting Css Class On Actionlink?

Oct 19, 2010

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:

[Code]....

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 ?

View 10 Replies


Similar Messages:

Setting Page Title From An HtmlHelper Class?

Sep 23, 2010

I have an HTML Helper that essentially renders static content read from HTML files (inside of a vdir). There are cases when the HTML file has a title element defined and in such cases, the current page should use the given title. The content inside of the body should be rendered where the Helper class is referenced in the View.

This is how I call the helper.

<%=Html.StaticContent("staticcontent.htm",
new List<StaticContentTag>()
{
new StaticContentTag()
{TagKey=ReplaceTags.MarketName,
TagValue = "Austin"}
}, Model, true) %>

I'm passing in the ViewModel so that I can set the title and the last parameter is a flag that says whether to force the title or not.

The head has the title defined like this.

<title><%=Model.Title%></title>

I know what I'm doing wrong here by referencing the Model.Title element before even calling the helper. Any ideas on how I can work around this?

View 1 Replies

Setting The Class Of Htmlanchor On Server Side Using Vb?

Jul 31, 2010

i just learnt how to add the anchor dynamically to mysite.

but i don't know how to set the class for the htmlanchor

below is the code:

[Code]....

the point is I can't find( or missed it,) the htmlAnchor attribute for setting the css class of the anchor.

View 2 Replies

How To Make The Setting Works For Class Library Project In C# 2.0

Jan 29, 2010

I am putting the setting under the property of one of my C# Class Library project for app setting:

EUCAccountService_ConnectionString
EUCTelcoDB_ConnectionString

In the development, it works nicely. Until I deported to production, I realise that the component that use those thing .. it just hang. I found that under BIN when it compiled dewaCorp.EUC.TelcoDB.Data.dll.config and open up that file and turn out nothing.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
</configuration>

How to make this works? I thought by compiling it, it turned to some sort config file or something. But it didn't.

View 2 Replies

Gridview - Setting Column Header's Css Class From Code Behind

Jan 20, 2010

what I am trying to do is add a method to my gridview's sorting event to add a class to the column being sorted so the user can know if the data is being sorted ascending or descending and on what column. I am currently trying to do it through a switch statement on the sort expression to determine what column it's coming from but I am unaware of how to set the css class.

View 1 Replies

Web Forms :: Setting A Property In A Class That Adds A Web Part

Sep 24, 2010

When I add a WebPart to a page, I need to set a Property in the class that builds the WebPart.

In the CatalogZone, I declare:

[Code]....

In the CatalogPart1 class, I instantiate MyWebPart:

[Code]....

MyWebPart.PagePartID contains the correct value.

This calls MyWebPart which contains the property:

[Code]....

but vPagePartID is equal to nothing.

What am I doing wrong?

How do I get the value of PagePartID to MyWebPart?

View 2 Replies

Web Forms :: Setting Properties Within BasePage Class Not Working?

Jan 11, 2010

We are trying to use a BasePage class (which inherits from Page) to populate and set the Meta Keywords and Meta Description Tags. I am using masterpages and below is an example code extract... According to examples on the internet, I could then set this also via the Page Directive using the MetaKeywords and MetaDescription properties, but they do not appear.

I have tried setting the CodeFileBaseClass="MyNamespace.UI.BasePage" but this does not work either. Using debug I can see that the BasePage classes' MetaKeywords and MetaDescription properties are not being set within my content page. I can access the properties but not set them.

== BASEPAGE CLASS ==

[Code]....

== PAGE CLASS ==

[Code]....

View 3 Replies

Web Forms :: MasterPage - Setting Body Class Of ContentPage?

Aug 23, 2010

how to set the body class of a ContentPage when using master pages?

I want to set the body class so that certain elements of my page are styles differently from each other. e.g. Navigation links to so which is the current page.

View 4 Replies

C# - Setting Class-Level Variable To Use Between Event Handlers?

Mar 17, 2010

I'm having a hard time understanding why the following code doesn't work. I'm sure it's something remedial that I'm missing or not understanding. I currently have a page that asks for user input. If, based on the input and logged in user, I find data from this page already in the database, I need to update the existing records rather than creating new ones, so I set a class-level bool to true. The problem is, when MyNextButton is clicked, PreviouslySubmitted is still false. So, I'm not sure how to make the value of this variable persist.

public partial class MyForm : System.Web.UI.Page
{
private bool PreviouslySubmitted;
protected void Page_Load(object sender, EventArgs e)
{
MyButton.Click +=
(o, i) =>
{
q = from a in db.TableA
where (a.SomeField == SomeValue)
select a;
if(q.Any())
{
PreviouslySubmitted = true;
//populate the form's fields with values from database for user to revise
}
}
MyNextButton.Click +=
(o, i) =>
{
//the value of PreviouslySubmitted is false at this point,
//even if I made sure it was set to true the previous postback
if(PreviouslySubmitted)
{
//update database
}
else
{
//insert into database
}
}

View 2 Replies

Forms Data Controls :: Setting Html Of A DIV From Class File?

Mar 29, 2010

I am trying set HTML of a div from Class File [CDataOperations.cs]

I have written following code in this class file,

[Code]....

Object reference not set to an instance of an object. Div is used on the page as follows

<div id="oResultDiv" runat="server"> </div>

Code Must set Html from Class file.

View 8 Replies

MVC :: Setting Class For Action Link Programmatically In Site.master?

Dec 28, 2010

I have a menu made of an unordered list:

<ul id="navList">
<li id="homeTab">
<%: Html.ActionLink("Home", "Index", "Home")%>
</li> |
<li id="ourMissionTab">

[Code]....

I find the controller:

<% string controller = ViewContext.RouteData.Values["Controller"].ToString(); %>

then I would like to set the class for the li according to the controller value. How do I do that?

Something like: if controller == "home", then set the class for the li with the home id to active.

I just started learning MVC and am very new to the syntax. when you respond to this posting provide syntax, as I am coming from code behind background.

View 2 Replies

Localization :: Cannot Fix Or Limit User To Setting PC Regional Setting To UK

Dec 23, 2010

I have develop a web application. I have put my web application in my server and user can access from any location.

My server regional and setting is English (US). Now my problem is

1) When user access to my system and his pc setting is English (UK), it will prompt and error

and after i debug i suspect it is because of Datetime conflict (dd/MM/yyyy and MM/dd/yyyy)

2) I cannot fix or limit my user to setting his/her pc regional setting to UK

So what can i do in my web application solve this issue?

(Can i write any code in my client side (.aspx) to convert or do standardization to US)

View 2 Replies

Setting A JavaScript, JQuery Setting From Code Behind

Feb 11, 2010

I would like to set a value:

[code]....


...where [HERE] is the placeholder for my value, from my code behind in ASP.NET before the page is rendered. I generate a guid, and I need that apart of the script on the page.

View 2 Replies

How To Use Html.ActionLink()

Dec 18, 2010

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

C# - Get A Tooltip For ActionLink?

Mar 7, 2011

I think this should be simple, but I can't find the option! How do I get a tooltip/alt for my ActionLink??

<%=Html.ActionLink("New", "List", "FormSummary", new {childId = Child.Id}, new {Class = "action add"})%>

View 1 Replies

Passing The Value Of A Textboxfor Into ActionLink?

Oct 12, 2010

I am trying to pass the value that a user enters into a html.Textboxfor to an html.Action link. As shown below :

<%=Html.TextBoxFor(m => m.OrderQty)%>
<p class="button" >
<%: Html.ActionLink("Add to cart",
"AddToCart",
"ShoppingCart",
new { id = Model.Product.ProductId, Qty = Model.OrderQty }, "")%>
</p>

But when i put a breakpoint in the AddToCart Qty is always 0 :-(

View 1 Replies

Use An Asp:Button Like An Html.ActionLink?

Jul 4, 2010

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

MVC - Generate An ActionLink From Code Behind?

Jan 4, 2010

I have a number of permissions, and based on a set of conditions these permission determine if a user can see certain features. I have written a helper function for this as the logic in the view became quite extensive.

Essentially I'm looking for a function the same as Html.ActionLink that I can access from a class file (Ideally if I can access the Helper that would be great) So I can do somthing like so,

public static string GetAdminLinks()
{
if(PermCheck)
{
return(Html.ActionLink(...));
}
}

View 1 Replies

MVC :: ActionLink Calling The Method Twice?

Mar 3, 2010

I've a method associated with an actionlink in the asp.net mvc view. When user clicks on actionlink the method is being called twice before the user is redirected to an appropriate page. Following is the code.

Html.ActionLink(item.RecipientID,"EligibilityResponse","Eligibility",new { uid = item.Uid }, null)%>
public ActionResult EligbilityResponse(string uid)

View 5 Replies

MVC :: Cannot Call Different Controller Using Actionlink?

Feb 5, 2010

I have one problem with actionlink. My Example is: i have one view and controller named as XYZ.aspx and XYZ.vb controller , in this view i put below line

<%=Html.ActionLink("Manage", "Index", "Advertisement", New With {.aintCampaignid = Cam.CampaignID})%>

I have another view and controller named as Index.aspx and Advertisement.vb if click on manage link in XYZ view it will call to advertisement controller and index function But iam getting [URL], it wont call ..

View 2 Replies

MVC :: Possible ActionLink To A Different View / Controller?

May 13, 2010

I have the following code and wanted to know how to use the ActionLink par to to a page with a seperate controller/view and pass the Mode.ProjectId into this other controller/view.

View 4 Replies

MVC :: Trying To Use ActionLink With RouteValues And HtmlAttributes?

Nov 28, 2010

I am trying to use ActionLink with routeValues & htmlAttributes

[Code]....

View 3 Replies

MVC :: 3 - Ajax.actionlink Does Not Work

Mar 2, 2011

i have an application mvc3, created a link with ajax but confirm property does not works.

index.cshtml is
@{
View.Title = "Home Page";
}
@section Header{
<script src="../../Scripts/MicrosoftAjax.debug.js" type="text/javascript"></script>
<script src="../../Scripts/MicrosoftMvcAjax.debug.js" type="text/javascript"></script>
}
<h2>@View.Message</h2>
@Ajax.ActionLink(
"Delete Product",
"Delete",
new { id = 1 },
new AjaxOptions { HttpMethod = "DELETE", Confirm = "Are you sure?" }
)

and home controller delete action

public ActionResult Delete(int id)
{
return View();
}

but directly does delete page. how can i confirm box show?

View 6 Replies

MVC Submitting Form Using ActionLink

Feb 13, 2010

I am trying to use link to submit a form using the following code:

function deleteItem(formId) {
// submit the form
$("#" + formId).submit();
}

Basically I have a grid and it displays a number of items. Each row has a delete button which deletes the item. I then fire the following function to remove the item from the grid.

function onItemDeleted(name) {
$("#" + name).remove();
}

It works fine when I use a submit button but when I use action link the JavaScript from the controller action is returned as string and not executed.

public JavaScriptResult DeleteItem(string name)
{
var isAjaxRequest = Request.IsAjaxRequest();
_stockService.Delete(name);
var script = String.Format("onItemDeleted('{0}')", name);
return JavaScript(script);
}

And here is the HTML code:........................

View 3 Replies

MVC :: Use Conditional Values In ActionLink

Aug 25, 2010

Is it possible to use a condition inside an actionlink ?I would like to do this :

[Code]....

This will be used for some column sorting and if the current sort was asc the next sort has to be desc. The code above is not valid while compiling.

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved