Sourabh Choubey

Sourabh Choubey

  • NA
  • 236
  • 44k

call controller from xslt.

Aug 1 2016 2:30 AM


down votefavorite

i get error in anchor tag where i call controller(blog),actionname(index). I want my url looks likehttp://localhost:1882/blog/travels/1. Here travels is the name of parent and 1 is child id

This is my .xslt page:

 <xsl:for-each select="Parent"> <div class="grid-col-3"> <ul> <h4> <a href='@Url.Action("Index","Blog", new{{@ParentName}/{current()/@Id}}'> <xsl:value-of select="@ParentName"></xsl:value-of> </a></h4> <xsl:for-each select="/BlogCategories/BlogCategory[@ParentID = current()/@Id]"> <!--<xsl:if test="@ParentID=$Id">--> <li class="lis"> <a href="{@Name}/{current()/@ID}"> <xsl:value-of select="@Name"></xsl:value-of> </a> </li> <!--</xsl:if>--> </xsl:for-each> </ul> </div> </xsl:for-each>
 

i want to call this blog controller

         public ActionResult addblogxml(string actiontype)     {         if(actiontype== "Submit")         {             var blog = _api.GetAllBlogCategory().ToList();             StreamWriter writer = new StreamWriter(Server.MapPath("~/XmlFiles/BlogCategory.xml"));             writer.WriteLine(@"<?xml version=""1.0"" encoding=""utf-8""?>");                writer.WriteLine(blog[0]);             writer.Close();             var xDocument = XDocument.Load(Server.MapPath("~/XmlFiles/BlogCategory.xml"));             string xml = xDocument.ToString();             ViewBag.BlogCategoryXML = xml;         }         return View("~/Areas/BMS/Views/CategoryBlog/addblogxml.cshtml");     }

Answers (1)