.net-3.5

Asp.Net Mvc - Html.TextBox - Set Autofocus property

痴心易碎 提交于 2020-01-02 01:08:48
问题 In Html 5, there is a new attribute on textbox called autofocus. The problem is that it is a boolean value (there or not there) It should look something like : <input name="a" value="" autofocus> I tried : <%= Html.TextBox( "a", null, new { autofocus } ) %> But, it gives me an error because I'm not setting a value to autofocus... I know I can do it manually, but can I do it with Html.TextBox ? 回答1: Try <%= Html.TextBox( "a", null, new { autofocus = "" } ) %> According to the HTML5 spec on

C# 3.5 DLR Expression.Dynamic Question

强颜欢笑 提交于 2020-01-01 14:23:17
问题 I have inherited a small scripting language and I am attempting to port it to the DLR so that it is a little easier to manage. So far it has been fairly straight forward. I have run into a problem though attempting to dynamically call members of a variable. The current language runs on .NET and uses a parsing loop and reflection to do this, but I was hoping to get away from that. Here is an example of the script language: string $system1RemoteUri; string $dbconnection = $config

implicitly casting a generic<T> back to T

六月ゝ 毕业季﹏ 提交于 2020-01-01 09:11:46
问题 If I write a generic class like class MyGeneric<T> is it possible to write an implicit cast to type T, so I can do stuff like: public class MyGeneric<T> { ... } public class GenericProperties { public MyGeneric<string> MyGenericString {get;set;} public void UseMyGeneric() { string sTest = MyGenericString; MyGenericString = "this is a test"; } } Is it possible to do that by overloading operators? I know it could be done if my class wasn't a generic... 回答1: Well, yes, but for the love of zombie

Why am I getting a serialization error?

左心房为你撑大大i 提交于 2020-01-01 08:46:07
问题 I have the following code: class Program { static void Main(string[] args) { string xml = @"<ArrayOfUserSetting> <UserSetting> <Value>Proposals</Value> <Name>LastGroup</Name> </UserSetting> <UserSetting> <Value>Visible</Value> <Name>WidgetsVisibility</Name> </UserSetting> </ArrayOfUserSetting>"; List<UserSetting> settings = GetObjFromXmlDocument<List<UserSetting>>(xml); } public static T GetObjFromXmlDocument<T>(string xml) { T customType; XmlSerializer serializer = new XmlSerializer(typeof(T

Why am I getting a serialization error?

别等时光非礼了梦想. 提交于 2020-01-01 08:45:58
问题 I have the following code: class Program { static void Main(string[] args) { string xml = @"<ArrayOfUserSetting> <UserSetting> <Value>Proposals</Value> <Name>LastGroup</Name> </UserSetting> <UserSetting> <Value>Visible</Value> <Name>WidgetsVisibility</Name> </UserSetting> </ArrayOfUserSetting>"; List<UserSetting> settings = GetObjFromXmlDocument<List<UserSetting>>(xml); } public static T GetObjFromXmlDocument<T>(string xml) { T customType; XmlSerializer serializer = new XmlSerializer(typeof(T

What's the Best Way to Catch the Return Key in a PasswordBox? (WPF/XAML)

百般思念 提交于 2020-01-01 07:55:46
问题 What's the best way to catch the return key in a PasswordBox? (WPF/XAML) I have a TextBox field and a PasswordBox field on my login form (for username and password entry). I also have a login button which invokes the method that performs the login validation process. I need to make the Return key react the same way in the PasswordBox, so that the user can have the option enter their username and password and simply hit Return to log in. Does anyone know how this is done in WPF? Any help is

Recursive routine to obtain PropertyInfo

☆樱花仙子☆ 提交于 2020-01-01 05:33:07
问题 I'm attempting to create a recursive routine that will retrieve PropertyInfos for all members under a specified object (in .NET 3.5). Everything for immediate members is working, but it needs to parse nested classes as well (and their nested classes, etc). I do not understand how to handle the section that parses nested classes. How would you write this part of the code? public class ObjectWalkerEntity { public object Value { get; set; } public PropertyInfo PropertyInfo { get; set; } } public

Programmatically get ListItemVersion using client object model SharePoint 2010

巧了我就是萌 提交于 2020-01-01 05:01:46
问题 I have a scenario where I have to move all my data in a SharePoint 2010 list (name= "VersionTestList") to a SQL server database. Since versioning is enabled in the list, I want to move the previous version details too. Anyway I was able to move the latest item, but unfortunately I am not able to get the previous version data. I have tried this using Client Object Model and able to get the versions, but not able to get the ListItem of that corresponding version. Please find below the code

convert XmlNode to XNode?

 ̄綄美尐妖づ 提交于 2020-01-01 04:38:05
问题 Anyone know off the top of their heads how to convert a System.Xml.XmlNode to System.Xml.Linq.XNode? 回答1: I've never tried, but my first thought would be something like: XmlNode myNode; XNode translatedNode = XDocument.Parse(myNode.OuterXml); 回答2: Eric White's blog is the place to be for cool XML/XLINQ conversions and such. I know this question pre-date's the post but I found it while looking at some other Q, so maybe people still come across this a fair amount. His blog has plenty of

Is it possible to include a C# variable in a string variable without using a concatenator?

冷暖自知 提交于 2020-01-01 04:37:10
问题 Does .NET 3.5 C# allow us to include a variable within a string variable without having to use the + concatenator (or string.Format(), for that matter). For example (In the pseudo, I'm using a $ symbol to specify the variable): DateTime d = DateTime.Now; string s = "The date is $d"; Console.WriteLine(s); Output: The date is 4/12/2011 11:56:39 AM Edit Due to the handful of responses that suggested string.Format(), I can only assume that my original post wasn't clear when I mentioned " ...(or