Click here to Skip to main content
15,888,802 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have this regular code in a cshtml page that call the following controller.

@using (Html.BeginForm("Index", "Employees", FormMethod.Post))
{
    <!-- Example of a Checked Checkbox -->
    @Html.CheckBox("Example")
    <input type="submit" value="Submit your Form" />
}


[HttpPost]
     public ActionResult Index(bool Example)
     {
         if (Example)
         {
             HttpCookie cookie = new HttpCookie("Cookie");
             cookie.Value = "Hello Cookie! CreatedOn: " + DateTime.Now.ToShortTimeString();
             cookie.Expires = DateTime.Now.AddMinutes(5);
             this.ControllerContext.HttpContext.Response.Cookies.Add(cookie);

         }
         return RedirectToAction("Index");
     }



I would like to add the following code above it in a regular aspx page that is running MVC in the background. Please help .....Nor sure what is the syntax of the check box...

<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Website.Models.IndexViewModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
   Yummy. Test</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">


<% Html.RenderPartial("SubNavMenu",this.Model.snmvm, new ViewDataDictionary());  %>

<div class= "divSectionCopy">
    <div id="Disclaimer" style="padding-removed10px;">
    <p>
Does this work
    </p>
    <br /><br />

  <%
        try
        { %>
        <a id="acceptButton" >Accept</a>
    <%  }
        catch
        {%>
     <a id="a1" >Accept</a>
 <%} %>
    </div> 
    
    
   
</div>public ActionResult AcceptedDisclaimer(bool example)
        {

        
            var VideoView = new VideoViewModel();
            var MediaInfo = new mobile_media_listMobile_media();
            string URL;
            string modelYear = "", vehicleName = "", topicID = "";

            // disclaimer was accepted; now retrieve the video file information that was selected by the user
            // reconstruct the VideoView object by adding the
            // snmvm object reference back - this will be used by the Video view
            if (TempData["VideoView"] != null)
                VideoView = (VideoViewModel)TempData["VideoView"];

            if (TempData["snmvm"] != null)
                VideoView.snmvm = (SubNavMenuViewModel)TempData["snmvm"];

            if (TempData["MediaInfo"] != null)
                MediaInfo = (mobile_media_listMobile_media)TempData["MediaInfo"];

            if (TempData["modelYear"] != null)
                modelYear = (string)TempData["modelYear"];

            if (TempData["vehicleName"] != null)
                vehicleName = (string)TempData["vehicleName"];

            if (TempData["topicID"] != null)
                topicID = (string)TempData["topicID"];


            // clean-up TempData object no longer needed
            TempData.Remove("VideoView");
            TempData.Remove("snmvm");
            TempData.Remove("MediaInfo");
            TempData.Remove("modelYear");
            TempData.Remove("vehicleName");
            TempData.Remove("topicID");

            var topics = new TopicsViewModel(modelYear, vehicleName, topicID);

            // check the type of device being used...
            if (Request.UserAgent.ToUpper().Contains(WebConfigurationManager.AppSettings["BlackberryAgent"]))
            {
                URL = MediaLibrary.GetPlatformURL(WebConfigurationManager.AppSettings["3gpPlatform"], MediaInfo);
                if (!String.IsNullOrEmpty(URL)) return Redirect(URL);
            }
            // the following logic caused issues on iPhones and android devices only in the condition of the additional 
            // disclaimer being presented. Without this condition, the video is shown fine.
            //else if (Request.Browser.IsMobileDevice == true)
            //{
            //    URL = MediaLibrary.GetPlatformURL(WebConfigurationManager.AppSettings["DefaultPlatform"], MediaInfo);
            //    if (!String.IsNullOrEmpty(URL)) return Redirect(URL);
            //}
            else
            {
                return View("Video", VideoView);
            }

            //return null;
            return View(topics);
        }
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900