Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
O

onelopez

@onelopez
About
Posts
11
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • AngularJS: Why people prefer factory to share data between controllers
    O onelopez

    This SO should explain it rather well, https://stackoverflow.com/a/21900284

    JavaScript tutorial javascript com question announcement

  • JSON.Net - Error when I get value from a JToken that could be either a JValue or JArray
    O onelopez

    As you said, the value can be an actual integer or an array, when it's an array it attempts to cast the array as an integer and it returns null value, which causes the error. What needs to happen here, you need to check first if it's an array and then search in the array

    var roleFour = (from people in json.SelectTokens("DataFeed.People")
    .SelectMany(i => i)
    let ids = people["roleIds.int"]
    where (int) people["active"] == 1 &&
    (ids.Type == JTokenType.Array) ?
    ((int[]) ids.ToObject(typeof(int[]))).Any(k => k == 4) :
    (int) ids == 4
    select new {
    Id = (int) people["id"],
    ResAnFName = (string) people["firstName"],
    ResAnLName = (string) people["lastName"]
    });

    C# question csharp database xml json

  • I am still struggling to find a fix for this. Can some guru please help?
    O onelopez

    I understand what you are trying to do, but not really sure what you are asking... javascript code runs on the client side, the values set on #results are added after the client has loaded the javascript and calculated the distance. Are you attempting to send this data back to the server? you can always use a hidden input

    <input type="hidden" value="something" name="result" />

    or:

    <asp:HiddenField runat="server" ID="result" />

    which can then be ran on postback and checked for a value.

    ASP.NET help javascript com tools json

  • Moving duplicated 'return View("Index");' statments out of several multi exception catch blocks into a single block of code outside of the try/catch conditions
    O onelopez

    The problem is in the order of your code

    catch (Exception e)
    {
    ViewBag.result = "NotAuthenticated";

    return View("Index"); // This terminates the current method

    throw e; // Therefore, this never occurs
    }

    Change to this: (for testing purposes only)

    catch (Exception e)
    {
    ViewBag.result = "NotAuthenticated";

    throw e; // Throw it

    return View("Index"); // This piece will not execute.

    }

    ASP.NET help asp-net database architecture lounge

  • check array value exists
    O onelopez

    Use

    array.Any()

    . It's an extension method to

    IEnumerable<>

    if(array.Any(a => a!=null) ){
    // there's a non-null object here
    }

    http://msdn.microsoft.com/en-us/library/vstudio/bb337697(v=vs.100).aspx[^]

    C# data-structures tutorial

  • how to paginate like linkedin and facebook?
    O onelopez

    It's called "infinite" scrolling.... at least theoretically anyways. Here's an article that talks about it and you can even use his method http://tumbledry.org/2011/05/12/screw_hashbangs_building[^]

    Web Development com tutorial question announcement

  • WebException timeout Problem.
    O onelopez

    Double check your time again, the WebRequest class uses timeout in milliseconds, so if you did something like

    webRequest.Timeout = 180;

    That just means that it will expire in 180 milliseconds and not the expected 180 seconds. If your time is correct, then check with the server and make sure that the server does not close the connection after sometime without completing the request.

    ASP.NET help question

  • It does what now?
    O onelopez

    Granted you don't pass a null value, the component / control will always remain in

    .Visible = false

    But if false is passed, there's nothing there that will turn the control /component back on again.

    The Weird and The Wonderful question

  • Make the font red! No, black! Can we do both?
    O onelopez

    Try adding some table layout to that HTML code and you got something of which I find at work every day. Ohh... if that wasn't bad enough... try adding some random UI logic in classic ASP! Fun stuff!

    The Weird and The Wonderful ruby question

  • Reflection and Linq Extension Methods
    O onelopez

    There you go, sorts on properties of properties... not quite sure if it works with methods. The logic is there, but it's not fully tested

     public static IEnumerable SortObject(this IEnumerable ObjectToSort, string SortBy)
        {
            if (ObjectToSort == null)
                return null;
            if (string.IsNullOrEmpty(SortBy) == true)
                return null;
    
    		// Handle sorting on object methods as well as properties
            string\[\] tempSorts = SortBy.Split(',');
            List SortList = new List();
            bool inParanthese = false;
            string addString = string.Empty;
            foreach (string tempSort in tempSorts)
            {
                if ((tempSort.Contains("(") == true) && (tempSort.Contains(")") == false))
                {
                    inParanthese = true;
                }
                else if (tempSort.Contains(")") == true)
                {
                    inParanthese = false;
                }
                if (inParanthese == false)
                {
                    if (string.IsNullOrEmpty(addString) == false)
                    {
                        SortList.Add(addString + "," + tempSort.Trim());
                    }
                    else
                    {
                        SortList.Add(tempSort);
                    }
                    addString = string.Empty;
                }
                else
                {
                    if (string.IsNullOrEmpty(addString) == false)
                        addString += ",";
                    addString += tempSort.Trim();
                }
            }
            string\[\] Sorts = SortList.ToArray();
            bool Sorted = false;
            foreach (string FieldSort in Sorts)
            {
                string\[\] SubSort = FieldSort.Trim().Split(' ');
    
                string\[\] props = SubSort\[0\].Split('.');
                Type type = typeof(T);
                ParameterExpression arg = Expression.Parameter(type, "x");
                Expression expr = arg;
                foreach (string prop in props)
                {
                    System.Reflection.PropertyInfo pi = type.GetProperty(prop);
                    if (pi != null)
                    {
                        Sorted = true;
                        //expr = Expression.Property(expr, pi);
                        expr = Expression.MakeMemberAccess(expr, pi);
    
    C# linq csharp functional tutorial question

  • Can you call a method on an object that is null?
    O onelopez

    The compiler does not read an extension method as a method belonging to the instance object, instead it expands your code to something like:

    Console.WriteLine(ExtensionMethods.IsNull(o));

    Therefore, you do not get an exception.

    The Weird and The Wonderful csharp question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups