1. #371
    Ext JS Premium Member
    Join Date
    May 2008
    Posts
    372
    Vote Rating
    4
    ttbgwt is on a distinguished road

      0  

    Default


    Does this work with 4.2?

  2. #372
    Sencha User
    Join Date
    Apr 2013
    Posts
    9
    Vote Rating
    0
    JNickVA is on a distinguished road

      0  

    Default Multiple C# Views loaded from ExtJS

    Multiple C# Views loaded from ExtJS


    My ASP.NET MVC3/ExtJS application requires multiple Views that need to be maintained as C# code. What would be the best way to use these Views from the client-side ExtJS? Can a Ext.Direct call to a Controller Action, which returns a View, be used? What would the syntax be in the ExtJS code? If this isn't the best way to accomplish the task, what is? The way I see this working is for each C# View to have a <script> tag to load the ExtJS .js file for the client-side code.

  3. #373
    Sencha User
    Join Date
    Dec 2012
    Posts
    3
    Vote Rating
    0
    NicoExtForum is on a distinguished road

      0  

    Default


    Hi,
    it seems we found an issue using the lastest version in a non "en-Us" environnement : when used to call a method with a Date parameter, Ext.Direct.Mvc return an invalid date or an exception when parsing the String : this problem occurs with the basic sample included with the source.

    After looking at the source code, it seems the issue occurs in ReadJson method of the RequestDataConverter class where each JValue sent from the client are converted to string : if the JValue contains a DateTime the toString must specify the InvariantCulture to avoid parsing issue in the DirectValueProvider. To resolve the problem we've only add a check if the value is an IFormattable. Hence the following modification in the ReadJson method resolves the problem :

    Code:
    if (value is IFormattable)
    {
        data.Add(value == null ? null : ((IFormattable)value).ToString(null,CultureInfo.InvariantCulture));
    }
    else
    {
        data.Add(value == null ? null : value.ToString());
    }

  4. #374
    Sencha User
    Join Date
    Mar 2007
    Posts
    761
    Vote Rating
    1
    franklt69 is on a distinguished road

      0  

    Default Using Ext.Direct with RequestVerificationToken

    Using Ext.Direct with RequestVerificationToken


    HI, I need some help to use [ValidateAntiForgeryToken] in some methods inside controller

    I was trying something like that but i get error:

    Code:
    [ValidateAntiForgeryToken]
            public ActionResult GetList(int start, int limit)
            {
               
                if (ModelState.IsValid){
                    var total = db.Contacts.Count();
                    var contacts = db.Contacts.OrderBy(c => c.FirstName).ThenBy(c => c.LastName).Skip(start).Take(limit).ToList();
                    return Json(new {
                        total = total,
                        data = contacts
                    });
                }
                else
                {
                    return Json(new
                    {
                        message = "invalidrequest",
                       
                    });
                }
               
            }

    and from extjs I am doing it

    onDirectstoreBeforeLoad: function(store, operation, eOpts){
    var token = document.getElementsByName('__RequestVerificationToken').item(0).value;

    Ext.apply(Ext.getStore('MyDirectStore').getProxy().extraParams, {
    __RequestVerificationToken : token

    });
    }
    error:

    HTML Code:
    The required anti-forgery form field "__RequestVerificationToken" is not present.
    
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
    
    Exception Details: System.Web.Mvc.HttpAntiForgeryException: The required anti-forgery form field "__RequestVerificationToken" is not present.
    
    Source Error: 
    
    Line 268:            try {Line 269:                controller.ActionInvoker = new DirectMethodInvoker();Line 270

    any advice please

    regards
    Frank

  5. #375
    Sencha User
    Join Date
    Mar 2007
    Posts
    761
    Vote Rating
    1
    franklt69 is on a distinguished road

      0  

    Default


    I get this solution


    in the client side:

    Code:
    onDirectstoreBeforeLoad: function(store, operation, eOpts){
    var afth  = document.getElementsByName('__RequestVerificationToken').item(0).value;
    
    Ext.Ajax.defaultHeaders = {
        '__RequestVerificationToken': afth
    };
    }

    in the server side:

    I create this class: (thanks to http://richiban.wordpress.com/2013/0...ajax-requests/ )

    Code:
    [AttributeUsage(AttributeTargets.Class)]
        public class ValidateAntiForgeryTokenOnAllPosts : AuthorizeAttribute
        {
            public override void OnAuthorization(AuthorizationContext filterContext)
            {
                var request = filterContext.HttpContext.Request;
    
                //  Only validate POSTs
                if (request.HttpMethod == WebRequestMethods.Http.Post)
                {
                    //  Ajax POSTs and normal form posts have to be treated differently when it comes
                    //  to validating the AntiForgeryToken
                    if (request.IsAjaxRequest())
                    {
                        var antiForgeryCookie = request.Cookies[AntiForgeryConfig.CookieName];
    
                        var cookieValue = antiForgeryCookie != null
                                              ? antiForgeryCookie.Value
                                              : null;
    
                        AntiForgery.Validate(cookieValue, request.Headers["__RequestVerificationToken"]);
                    }
                    else
                    {
                        new ValidateAntiForgeryTokenAttribute()
                            .OnAuthorization(filterContext);
                    }
                }
    
            }
        }

    and then in the controller I add it:


    Code:
     [ValidateAntiForgeryTokenOnAllPosts]
        public class ContactsController : DirectController {


    regards
    Frank

  6. #376
    Sencha Premium Member
    Join Date
    Jun 2013
    Location
    Boulder, CO
    Posts
    538
    Vote Rating
    7
    DavidThi808 is on a distinguished road

      0  

    Default


    What/where is Basic.Echo?

    In main.js it calls Basic.Echo(). But I cannot find it documented anywhere. (Granted, a Google search on Basic.Echo finds a million other things first.) Where it is documented?

    thanks - dave

  7. #377
    Sencha Premium Member
    Join Date
    Jun 2013
    Location
    Boulder, CO
    Posts
    538
    Vote Rating
    7
    DavidThi808 is on a distinguished road

      0  

    Default


    Hi;

    I'm trying to figure out how MvcTest works. I think I understand about half of it (maybe). If anyone could explain the following, it would be very appreciated:
    1. ContactForm.js has load: Contacts.Get. That maps to ContactsController.Get. How? Does it use reflection on all DirectController child classes and on the name strip the Controller part off the name? (That's my best guess.)
    2. Contact.js and Contact.cs are the same class. Is either auto-generated (and if so how) or do I have to create both sides and make sure I match?
    3. The sample has <script type="text/javascript" src="@Url.Content("~/directapi?assembly=Test")"></script> - is there documentation of what params can be passed to directapi?
    4. What are WebApiConfig, FilterConfig, & RouteConfig doing? Is that part of the plumbing between the server & client side? And do I need to understand it or do I just copy what is there for any app using this? (Even if I can just copy it blindly, is it explained anywhere? I'd like to understand it.)
    5. Can I put the client side in a separate project from the server side? I want to create the client side in Sencha Architect.
    thanks - dave

  8. #378
    Touch Premium Member
    Join Date
    Nov 2011
    Posts
    124
    Vote Rating
    0
    JavascriptParrot is on a distinguished road

      0  

    Default


    Hello,

    I'm have some troubles with parsing dates, we build a application with is used in different time zones. While using the ISO datetime parser Ext JS see it as a string, so you have to parse it manually. When using the JS parser the client time zone is added what result in different time between the client and server.

    How do you handle datetime fields?

    Thanks

  9. #379
    Sencha Premium Member
    Join Date
    Mar 2012
    Location
    New Zealand
    Posts
    104
    Vote Rating
    15
    wayne.rudd will become famous soon enough

      1  

    Default


    I get around the timezone problem by putting in a convert function on the model fields that are dates to explicitly convert the string representation to a date


    //2012-11-12T00:00:00
    var thedate=new Date(v.substr(0, 4), v.substr(5, 2) - 1, v.substr(8, 2), v.substr(11, 2), v.substr(14, 2));

    return thedate;

  10. #380
    Touch Premium Member
    Join Date
    Nov 2011
    Posts
    124
    Vote Rating
    0
    JavascriptParrot is on a distinguished road

      0  

    Default


    Nice!
    Do you use the IsoDateConvert or the JavascriptConvert for serializing?

    Thanks

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi