MVC :: Converting Underscores In Anonymous Objects To Hyphens?

Dec 2, 2010

anonymous attributes with underscores are supposed to render as hyphens to allow unobtrusive ajax attributes.

It works fine for this:

@Html.TextBox("Name","Value", new {data_unobtrusive_attr="attrValue"})

gets correctly rendered as this:

<input type="text" name="Name" value="Value" data-unobtrusive-attr="attrValue" />

However, it doesn't work for the Ajax.BeginForm helper (kinda the most important place for that to work!) -- the underscores just stay as underscores.

View 5 Replies


Similar Messages:

Web Forms :: ValidationExpression To Just Accept A-Z, 0-9 / Hyphens / Underscores / Spaces?

May 11, 2010

Using a RegularExpressionValidator, I want my textbox to accept a max of 20 chars, and only English characters A-Z (upper and lowercase), 0-9, hyphens (-), underscores (_), and spaces. That's it.

Now that I think about it, since this text will be used by a proprietary software to create a file of the same name, and will also be included in the querystring when the page is redirected (so that I can find the file so the user can download it), I'm not sure if I should keep it safe and not accept spaces.

View 4 Replies

C# And Arrays Of Anonymous Objects?

Jan 9, 2010

what does such expression mean?

obj.DataSource = new[]
{
new {Text = "Silverlight", Count = 10, Link="/Tags/Silverlight" },
new {Text = "IIS 7", Count = 11, Link="http://iis.net" },
new {Text = "IE 8", Count = 12, Link="/Tags/IE8" },
new {Text = "C#", Count = 13, Link="/Tags/C#" },
new {Text = "Azure", Count = 13, Link="?Tag=Azure" }
};

especially these lines new {Text = "IIS 7"... how can I create such array manually to suite this DataSource

View 6 Replies

C# And Anonymous Types - Iterate Through A DataTable While Manually Building An Anonymous Type

Jan 18, 2010

I am currently implementing a client-side paging solution using ASP.NET, jQuery and JSON.

I have been following the excellent article from encosia: http://encosia.com/2008/08/20/easily-build-powerful-client-side-ajax-paging-using-jquery/

In my Web Method I retrieve my data from the database as a DataTable:

DataTable categoryProducts = ProductViewerAccess.GetCategoryProducts
("AA", 4, 0, Page.ToString(), out howManyPages, "FALSE", 0, "CostPrice", "asc", destinationList);

I then retrieve the data from the DataTable into an anonymous type:

var feeds =
from feed in categoryProducts.AsEnumerable()[code]....

This all works great.

However, I would like to extend the code to perform some evaluation checks (e.g., check that various columns in the DataTable are not NULL) and other pre-processing (e.g., call various functions to build the image URL based on the image ID - which is another column in the DataTable not shown in the code fragment) before I return the resulting rows of the DataTable as an anonymous type to the client-side.Basically, I want to iterate through the DataTable, perform the evaluation checks and pre-processing, while building my anonymous type manually as I go. Or maybe there is a better way to achieve this?

View 2 Replies

How To Allow Hyphens In URLs For Mvc 2 Controller Names

Mar 12, 2011

[ActionName("about-us")]
public ActionResult EditDetails(int id)
{
// your code
}

The above works for actions but I would like to be able to do the same (or similar) for controllers, ie have a hyphen in the URL name too. Is there any easy way to achieve this (I tried the ActionName attribute but no luck)

View 2 Replies

DataSource Controls :: How To Hyphens In Field Data

Apr 13, 2010

Once again, I find myself stuck!

I am attempting to compare one of ASP.NET's membership userID's with the current userID in an SQL query, however because of the "hyphens -" in the uniqueidentifier field type of userID, i am unable to compare the ids. is there a way around this? (in my example, family_id from tblFamily is the userID that has type uniqueidentifier). my code as it stands is:

Dim UserID As String = New String(Membership.GetUser(User.Identity.Name).ProviderUserKey.ToString())
Response.Write(UserID)
Dim strConn As String = ConfigurationManager.ConnectionStrings("ApplicationServices").ConnectionString
Dim SQLI As New Data.SqlClient.SqlCommand("SELECT family_name FROM tblFamily WHERE [family_id] IS " & UserID & "")
Dim sqlCon As New Data.SqlClient.SqlConnection(strConn)
sqlCon.Open()
SQLI.Connection = sqlCon
Dim RSI As Data.SqlClient.SqlDataReader = SQLI.ExecuteReader()
RSI.Read()
Dim FamilyName As String = "0"
While RSI.Read
FamilyName = Convert.ToString(RSI("family_name"))
End While
Response.Write(FamilyName)
RSI.Close()
sqlCon.Close()

View 6 Replies

MVC2 Not Replacing Underscores With Dashes In HtmlAttributes?

Nov 9, 2010

I've heard from a couple of different sources that when using HTML helpers in ASP.NET MVC2, one can create custom attributes with dashes in them (e.g. <a data-rowId="5">) by using an underscore in place of the dash, and when the HTML is written to the page the underscores will be replaced by dashes.

So, something like this:

<%= HtmlActionLink(Model.Name, "MyView", null, new {data_rowId = Model.id}) %>

should render as

<a data-rowId="0" href="myURL">Row Name</a>

But... it's not. I think that maybe this feature is only enabled in the MVC3 Beta preview (as it's mentioned in the MVC3 preview release notes), but this thread is about the same thing, and it's regarding MVC2.

I know I can use the other solution presented in that thread, but I'd rather not have to resort to using the dictionary if a more elegant solution exists.

View 2 Replies

WCF / ASMX :: Svcutil Generates Underscores In Enum With Type Int?

Feb 8, 2011

i am generating a wcf data contract from a schema, using svcutil /d: option, however the enum of type xsd:int in schema is generating all the values as ints, with underscores, obviously to make valid code. How can i get the actual value of 1000

E.g Enum Impact with values 1000,2000,3000 generates code

public enum Impact : int
{
[System.Runtime.Serialization.EnumMemberAttribute(Value = "1000")]
_1000 = 1,
[System.Runtime.Serialization.EnumMemberAttribute(Value = "2000")]
_2000 = 2,
[System.Runtime.Serialization.EnumMemberAttribute(Value = "3000")]
_3000 = 3
}

View 2 Replies

Forms Data Controls :: Binding A Repeater To A List Of Objects That Have Child Objects?

Nov 17, 2010

have some Objects, lets say Employee and Role defined as below and I have defined relationships in my database that gives me a list of objects say employees and thanks to my framework each employee object also has a Role object linked via the RoleIDID, UserName, Password, Email, RoleIDRoleID, RoleNameSo in code I can do something like this

Employee emp = dataService_GetEmployeeByID(1);
string RoleName = emp.Role.RoleName;

Now here is my problemI can bind any object in a repeater and it works fine for the first level in my relationship

For instance <%# Eval("UserName") %>

But I need to be able to show the details for my child objects as well (Role) so something like this (which does not work)

<%# Eval("Role.RoleName") %>

View 2 Replies

Forms Data Controls :: Binding An Objects(containing Sub Objects) To A Dropdown List?

Apr 6, 2010

I know how to bind a simple objects to a dropdown list. However I am having problems binding my objects which contains sub objects to the control.i.e. with simple object i just do ddl.DataValueField = "myproperty"
with my objects they contains sub objects which i want to bind. I have tried ddl.DataValueField = "sub-object.myproperty" which doesnt work.

View 2 Replies

Architecture :: Using Static Methods To Build User Objects And Various Other Objects?

Jun 21, 2010

firstly a static class only ever exists once and is not an instance. Any static members (ie static int NoOfPeople;) is stored in one place and is shared between all sessions (like the old global variables).
Now static methods is where i'm not 100% sure. If I have a static method that doesn't use any other static members could this cause inconstant results, example (this is a fairly pointless method but just a quick example of the top of my head)

[Code]....

So in this example if two sessions (or threads) were to call this at the same time - would they both get back the expected results, because the method only uses private data (a, b and totalToReturn).Im sure this sounds a little simple but I will be using static methods to build user objects and various other objects that there will have to be a 100% garentee that the objects will not get mixed up between sessions and the wrong things return to the user.

View 5 Replies

Dynamic Data Be Made To Work With Custom Business Objects Rather Than Data Objects?

Feb 24, 2010

I'm working on a project in which we have a database, data layer (entity framework), business layer and web/UI layer.I want to use ASP.NET Dynamic Data for the web layer, but don't want it to access the data layer or database, as I want it to be purely running off business logic, and not directly accessing the data.However, it appears that Dynamic Data only allows Linq-to-SQL or entity framework data sources to be used.Has anyone used it with business-layer objects instead?

View 1 Replies

State Management :: How To Link The Objects Between Browser Session And Session Objects

May 10, 2010

Lets say I am doing a shoping cart. I authenticate the user with a session variable.For example:

If(Request.IsAuthenticated)
// Here I want to add to the shoping cart.
// Can I do the following
Session["Cart"] = "Washing Machine";
Now will this Session["Cart"] value which is washing machine here be unique to diff customers?

View 1 Replies

What Application Objects Or System Objects Are Stored In The Application Pool

Feb 1, 2010

I hosted my application in production. Within 5 to 6 hours the application pool spikes and uses more memory?

What application objects or system objects are stored in the application pool?

View 3 Replies

Anonymous Access Disabled?

May 5, 2010

My web app (asp VB 2005) uses Windows authentication. If the user isn't part of a specific AD security group they don't get to edit the data; instead I redirect the user to a read-only page.The program works fine in the IDE.I published the web app to my laptop and Disabled anonymous access. When I ran the program I got redirected to the read-only page. I added a write event to the application event log to see what was going on, and found that the WindowsPrincipal.Identity.Name contained my laptop's ID, not my user name.I reassert: anonymous access is disabled in IIS and the web.config file has Windows Authentication.

View 1 Replies

Redirecting Anonymous Users IIS 7?

Sep 22, 2010

I am working on an internal application... i setup IIS 7 to use windows authentication since its behind the firewall and on the domain.. there is a "public" side.. and an "internal" side... if your not part of IT.. you should get the public side.. this is just informational.. my problem is that there is 1 or two pcs that are not on the domain and nobody is logged into them.. how can i just redirect anonymous users to another site?

everything i read says you can't use anonymous AND windows auth.. so my thought was to just redirect the anonymous users to another site.. how can you do that?

View 1 Replies

.net - Get Properties From Anonymous Type In VB.NET?

Feb 12, 2010

I am trying to figure out how to get at an anonymous typed object's properties, when that anonymous type isn't created in the current function.

Specifically, I am binding an ASP.NET ListView to LINQ resultset, then trying to process each item in the ItemDataBound event.

Option Explicit On
Option Strict On
Class MyPageClass
Private Sub Bind()
Dim items As ItemData = FetchItemData()
Dim groups = From s In items Group s By Key = s.GroupId Into Group _
Select GroupID = Key, GroupData = Group
' This works fine:
Dim groupId As Integer = groups(0).GroupID
lvGroups.DataSource = groups
lvGroups.DataBind()
End Sub
Private Sub lvGroups_ItemDataBound(ByVal sender As Object, ByVal e As ListViewItemEventArgs) Handles lvGroups.ItemDataBound
If e.Item.ItemType = ListViewItemType.DataItem Then
Dim item As ListViewDataItem = DirectCast(e.Item, ListViewDataItem)
Dim groupData = item.DataItem ' This is the anonymous type {GroupId, GroupData}
' Next Line Doesn't Work
' Error: Option Strict disallows late binding
Dim groupId As Integer = groupData.GroupId
End If
End Sub
End Class

What do I need to do in lvGroups_ItemDataBound() to get at the item.DataItem.GroupId?

View 2 Replies

C# - Databind Using An Anonymous Type?

Feb 16, 2011

Basically, I have a repeater control, and a Linq query that retrieves some items. Ordinarily I would databind straight to the query and use Eval to populate the template with the results.

However, it doesn't come through in quite the right format - for example, if EndDate is null (it's a DateTime?) then I want to substitute it with "Present". I am using only a couple of the properties in the query result objects.

I am wondering if there's a solution like:

[pseudo madeup code]
var query = getResults();
List<anonymous> anonList = new List();
foreach (var q in query)
{
string myEndDate = "";
if (q.EndDate.HasValue)
{ myEndDate = q.EndDate.ToString(); }
else
{ myEndDate = "Present"; }
anonList.items.add(new { name=q.name, enddate=myEndDate };
}
repeater.Datasource = anonList;

then

<div><%#Eval("enddate")%></div>

View 3 Replies

ADO.NET :: Get Property Of Anonymous Type?

Jan 31, 2011

I use LinqToSql in my project. I have a class called MessageBLL and this class has a method called GetAll which returns List<object>. I returned object because I get data from two tables. Here is my code;

[Code]....

I want to use this in my Default.aspx.cs as like this but intellisense is not show CategoryName :[Code]....suggest me return as IQueryable but I couldn't do it in that way.

View 6 Replies

Web Forms :: Anonymous Profile In MVC With Postgre?

May 21, 2010

I have a Postgre profile provider that runs ok with membership, roles, profiles etc.. But I have a problem.I'm trying to have a anonymous user profile but the provider get an error when I try to save the profile.It says:

Error 23503: insert or update on table "profiles" violates foreign key "pofiles_username_fkey"I configured my web.config with anonymousIdentification enabled, and profile ok, But it seems that when the profile saves, it can not find the anonymous user in the users tables that it's related with profles user. I googled for long time and I think I have all good configurated, but somehow, profiles with anonymous user is not working.

View 9 Replies

Web Development - Configure Caching For Anonymous Only?

Feb 25, 2010

I'm looking for a way to configure caching only for anonymous users only. The reason I'm looking to do this is when users are logged in and they create content they don't immediately see the content. In our old system (linux/php/mysql) we had it configured to cache only the anonymous users and this wasn't an issue.

Right now we have caching setup in the web.config like this

[code]....

I know that I can add a varyByCustom="userName" like this post is talking about. But this doesn't solve my problem. It still caches the users login and the same problem exists.

View 2 Replies

Security :: How To Create Anonymous User

Dec 4, 2010

is there any method in .net framework to create a anonymouse user programaticly or i have to write a method?

View 6 Replies

How To Return Anonymous Type While Using Linq

Jun 30, 2010

Do any one know how to return an anonymous type. I am using Linq where i need to return the following code

private <What's the return type to be provided here> SampleLinq(Int32 Num)
{
var query = (from dept in obj.DeptTable where dept.Id == Num select new { dept.DeptName, dept.DeptId });
return (query)
}

View 8 Replies

MVC :: Using An Anonymous Function For An Action Result?

Oct 14, 2010

i can assign a simple anonymous function and it works, but i'm having trouble with a more complex one.

i am attempting to disable an image button after it is pressed.

any alternatives would be welcome, but i think this is the recommended

[Code]....

View 2 Replies

Authorize A Directory For Anonymous Users IIS 7.5?

Feb 4, 2011

I'm trying to add a directory for anon access in IIS 7.5. It works under Web Dev but not IIS 7.5

I'm currently using this web.config in the directory. This is a directory with style sheets:

<?xml version="1.0"?>

Note: As an alternative to hand editing this file you can use theweb admin tool to configure settings for your application. Use the Website->Asp.Net Configuration option in Visual Studio. A full list of settings and comments can be found in machine.config.comments usually located in WindowsMicrosoft.NetFrameworkv2.xConfig

<configuration>
<appSettings/>
<connectionStrings/>
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</configuration>

Update:

I've went to the folder and under Authentication, I've changed anonymous authentication from IIS_USR to pool. This seems to have correct it.

I will reward anyone who provides a very good explanation and resources for understanding this setting. Also, how to apply it globally would be good to know -- for all folders.

View 2 Replies







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