Search Results

Search found 3 results on 1 pages for 'bflemi3'.

Page 1/1 | 1 

  • Find XmlNode where attribute value is contained in string

    - by bflemi3
    I have an xml file... <?xml version="1.0" encoding="UTF-8"?> <items defaultNode="1"> <default contentPlaceholderName="pageContent" template="" genericContentItemName="" /> <item urlSearchPattern="connections-learning" contentPlaceholderName="pageContent" template="Connections Learning Content Page" genericContentItemName="" /> <item urlSearchPattern="online-high-school" contentPlaceholderName="pageContent" template="" genericContentItemName="" /> </items> I am trying to find the first node where the urlSearchPattern attribute is contained in the string urlSearchPattern. Where I'm having trouble is finding the nodes where the attribute is contained in the string value instead of the string value be contained in the attribute. Here's my attempt so far. This will find the firstOrDefault node where the string value is contained in the attribute (I need the opposite)... string urlSearchPattern = Request.QueryString["aspxerrorpath"]; MissingPageSettingsXmlDocument missingPageSettingsXmlDocument = new MissingPageSettingsXmlDocument(); XmlNode missingPageItem = missingPageSettingsXmlDocument.SelectNodes(ITEM_XML_PATH).Cast<XmlNode>().Where(item => item.Attributes["urlSearchPattern"].ToString().ToLower().Contains(urlSearchPattern)).FirstOrDefault();

    Read the article

  • How to serialize each item in IEnumerable for ajax post

    - by bflemi3
    I have a PartialView that displays IEnumerable<Movie>. _MoviePartial.cshtml @foreach(var movie in Model) { <div class="content"> <span class="image"><img src="@movie.Posters.Profile" alt="@movie.Title"/></span> <span class="title">@movie.Title</span> <div class="score`"> <span class="critics-score">@movie.Ratings.CriticsScore</span> <span class="audience-score">@movie.Ratings.AudienceScore</span> </div> @Html.ActionLink("Add Movie", "Add", "MyMovies") </div> } When the user clicks the "Add Movie" ActionLink I am going to do an ajax post to add the selected movie to the users collection. My problem is that I would like to send the entire selected Movie class to the "Add" action but not sure how to serialize each movie since the entire Movie class is not rendered in the PartialView, just a few properties. I know I can serialize something like this... <script type="text/javascript"> var obj = @Html.Raw(Json.Encode(movie)); </script> But I'm not sure how that would work inside a foreach loop that renders html, especially inside a PartialView. So, just to be clear, when a user clicks the "Add Movie" ActionLink I would like to send the serialized Movie class for that respective movie to my controller via ajax. My questions is... Is there a better way to serialize each movie and append it to it's respective anchor? I know there's the data- html5 attribute but I thought they only allow string values, not json objects. I also know I could use jQuery's .data() function but I'm struggling to think through how to get that to run from a PartialView, especially since the html rendered by _MoviePartial.cshtml may be returned from a controller via ajax.

    Read the article

  • Refactoring two methods down to one

    - by bflemi3
    I have two methods that almost do the same thing. They get a List<XmlNode> based on state OR state and schoolType and then return a distinct, ordered IEnumerable<KeyValuePair<string,string>>. I know they can be refactored but I'm struggling to determine what type the parameter should be for the linq statement in the return of the method (the last line of each method). I thank you for your help in advance. private IEnumerable<KeyValuePair<string, string>> getAreaDropDownDataSource() { StateInfoXmlDocument stateInfoXmlDocument = new StateInfoXmlDocument(); string schoolTypeXmlPath = string.Format(STATE_AND_SCHOOL_TYPE_XML_PATH, StateOfInterest, ConnectionsLearningSchoolType); var schoolNodes = new List<XmlNode>(stateInfoXmlDocument.SelectNodes(schoolTypeXmlPath).Cast<XmlNode>()); return schoolNodes.Select(x => new KeyValuePair<string, string>(x.Attributes["idLocation"].Value, x.Value)).OrderBy(x => x.Key).Distinct(); } private IEnumerable<KeyValuePair<string, string>> getStateOfInterestDropDownDataSource() { StateInfoXmlDocument stateInfoXmlDocument = new StateInfoXmlDocument(); string schoolTypeXmlPath = string.Format(SCHOOL_TYPE_XML_PATH, ConnectionsLearningSchoolType); var schoolNodes = new List<XmlNode>(stateInfoXmlDocument.SelectNodes(schoolTypeXmlPath).Cast<XmlNode>()); return schoolNodes.Select(x => new KeyValuePair<string, string>(x.Attributes["stateCode"].Value, x.Attributes["stateName"].Value)).OrderBy(x => x.Key).Distinct(); }

    Read the article

1