locked
Retreiving the action RRS feed

  • Question

  • User1983774555 posted
    I want to use one template for Details, Edit and Insert. Therefore I have added the following lines to Global.asax.cs: routes.Add(new DynamicDataRoute("Archiefdoos/Edit.aspx") { Constraints = new RouteValueDictionary(new { action = "Details|Edit|Insert" }), Model = model, Table="Archiefdoos" }); This works fine, all three actions show the same page. Now I want to make the page do different things depending on which action we are dealing with. For instance, if the action is Edit I want to set the property Mode on all DynamicControls to 'Edit', if the action is Details, I want to set Mode to 'ReadOnly', etc. Is it possible to find out in code behind what the action is?
    Friday, September 12, 2008 8:59 AM

All replies

  • User-330204900 posted

    You certainly can you could use the DetailsView1.CurrentMode

    returns the Current Mode Edit, Insert or ReadOnly

    Hope this helps [:D]

    Friday, September 12, 2008 9:57 AM
  • User1641955678 posted

    To get the real action coming from the route, try this:

        RequestContext requestContext = DynamicDataRouteHandler.GetRequestContext(Context);
        string action = (string)requestContext.RouteData.Values["action"];
    
     

    thanks,
    David

    Friday, September 12, 2008 11:51 AM