asp.net-webpages

How can I access a single XML element's value using C#.net web-pages with WebMatrix?

情到浓时终转凉″ 提交于 2019-12-04 23:51:05
问题 I've looked at a lot of resources, done a lot of research, and tried many "best-guesses" to access a single element at a time using WebMatrix with C#, web-pages, however nothing I am trying is getting through. Consider a simple xml document that looks like this: <root> <requisitionData> <element1>I am element 1</element1> <element2>I am element 2</element2> </requisitionData> </root> I know I can use a foreach loop, like so: @using System.Xml.Linq XDocument doc = XDocument.Load(Server.MapPath

How can I access a single XML element's value using C#.net web-pages with WebMatrix?

一曲冷凌霜 提交于 2019-12-03 15:24:53
I've looked at a lot of resources, done a lot of research, and tried many "best-guesses" to access a single element at a time using WebMatrix with C#, web-pages, however nothing I am trying is getting through. Consider a simple xml document that looks like this: <root> <requisitionData> <element1>I am element 1</element1> <element2>I am element 2</element2> </requisitionData> </root> I know I can use a foreach loop, like so: @using System.Xml.Linq XDocument doc = XDocument.Load(Server.MapPath("~/User_Saves/cradebaugh/testFile.xml")); foreach (XElement element in doc.Descendants(

Conflicting versions of ASP.NET Web Pages detected: specified version is “1.0.0.0”, but the version in bin is “2.0.0.0” in ASP.MET MVC 3

女生的网名这么多〃 提交于 2019-12-03 09:24:06
I am getting the following error after installing microsoft web helper: Conflicting versions of ASP.NET Web Pages detected: specified version is "1.0.0.0", but the version in bin is "2.0.0.0". To continue, remove files from the application's bin directory or remove the version specification in web.config. From what I read, I might have tried instaling the wrong version. But how do i orrect this? So far, I have uninstall the microsoft web helper Deleted and content of the bin folder and rebuild the project Replace my web.config file with a new file with all defaults (given i did not change much

How can I reference data from an AppState variable?

只谈情不闲聊 提交于 2019-12-03 00:55:18
问题 The problem is that I can't find a way to test anything stored in AppState["variableName"] (or App.variableName or HttpContext.Current.Application["variableName"], etc.) inside an if condition. (It only ever sees it as an object, even though I can plot it on the page with Razor as the string variable I thought it was) So, I can't compare them to say an actual string value. I've tried ToString(), among countless other attempts, to no avail. My question is: How can I achieve full functionality

Error when using LINQ with anonymous classes and implicitly typed arrays in ASP.NET WebPages

▼魔方 西西 提交于 2019-12-02 18:28:19
问题 I am trying to mock up a page using WebMatrix using WebPages under the hood. I have assigned an implicitly typed array of anonymous objects to one of the PageData keys, but I get the following error when I try to using LINQ methods on the collection: CS1977: Cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree type Here is some sample code: @{ PageData["Vals"] = new [] { new { ID=1, Quantity=5 }, new { ID

Error when using LINQ with anonymous classes and implicitly typed arrays in ASP.NET WebPages

核能气质少年 提交于 2019-12-02 10:08:41
I am trying to mock up a page using WebMatrix using WebPages under the hood. I have assigned an implicitly typed array of anonymous objects to one of the PageData keys, but I get the following error when I try to using LINQ methods on the collection: CS1977: Cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree type Here is some sample code: @{ PageData["Vals"] = new [] { new { ID=1, Quantity=5 }, new { ID=2, Quantity=3 } }; var sum = PageData["Vals"].Sum(x => x.Quantity); } If I first store the array in a

ASP.NET WebPages use html extension

送分小仙女□ 提交于 2019-12-01 08:06:34
I'm trying to use ASP.NET WebPages to make sense of an existing site which uses static .html files (about 500 of them). Unfortunately, my SEO person is requiring that the site maintains its existing directory / filenames, so I need to use .html. After finding this example , I tried adding the extension in web.config under compilation/buildProviders/ as: <add extension=".html" type="System.Web.WebPages.Razor.RazorBuildProvider"/> And adding an Assembly as well: <add assembly="System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> This still doesn't

ASP.NET WebPages use html extension

允我心安 提交于 2019-12-01 06:49:08
问题 I'm trying to use ASP.NET WebPages to make sense of an existing site which uses static .html files (about 500 of them). Unfortunately, my SEO person is requiring that the site maintains its existing directory / filenames, so I need to use .html. After finding this example, I tried adding the extension in web.config under compilation/buildProviders/ as: <add extension=".html" type="System.Web.WebPages.Razor.RazorBuildProvider"/> And adding an Assembly as well: <add assembly="System.Web

InvalidCastException is thrown after installing ASP.NET MVC 4 Beta

丶灬走出姿态 提交于 2019-11-30 11:44:19
问题 I get the following exception after installing ASP.NET MVC 4 Beta on a machine with ASP.NET MVC 3. System.InvalidCastException was unhandled by user code Message=[A]System.Web.WebPages.Razor.Configuration.HostSection cannot be cast to [B]System.Web.WebPages.Razor.Configuration.HostSection. Type A originates from 'System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' in the context 'Default' at location 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System

Asp:FileUpload edit “No file selected” message

喜你入骨 提交于 2019-11-30 10:15:50
I just need to know if there's a way to change the message shown by the Asp:FileUpload when no file as been selected. Thanks. You replace the text with your own message using CSS pseduo-class :after . You can declare a class like this one: .bar:after { content:"Please select a file"; background-color:white; } And assign it to your FileUpload control. The content message will replace the original one. Of course upon file selection you need to remove the message, you can do this for example via jQuery .removeClass (assuming ID of your FileUpload is "foo"): $('#foo').change(function() { $(this)