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
L

Liagapi

@Liagapi
About
Posts
41
Topics
24
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Cannot Create and Return an Instance of a Class
    L Liagapi

    Suppose in my project I'm referencing another project as follows:

    using static ProjectA;

    Prior to using the static keyword in the using statement, one of my methods was able to create an instance object of a class called Products from ProjectA, set the values of its members, and return the instance object of this class as shown below:

    Product prod = new Models.Product();
    prod.ID = unit.ID;
    prod.Dept =unit.Department;
    return prod;

    Now I'm getting errors stating that I cannot use an instance object to access members of the Product class. I tried to resolve this issue by going to the Product class in ProjectA, adding the static keyword to the ID and Dept properties, and creating a static constructor. I can now set values of the ID and Dept properties using the class name as shown below:

    Product.ID = unit.ID;
    Product.Dept =unit.Department;

    The only problem I have now is I'm still getting an error stating that I cannot use an instance object to access members of the Product class on the line Product prod = new Models.Product();. Please point out what I'm doing wrong.

    C# help

  • How To Return an Instance of a Non-Static Class With Static Members
    L Liagapi

    Suppose in my project I'm referencing another project as follows:

    using static ProjectA;

    Prior to using the static keyword in the using statement, one of my methods was able to create an instance object of a class called Products, set the values of its members, and return the instance object as shown below:

    Product prod = new Models.Product();
    prod.ID = unit.ID;
    prod.Dept =unit.Department;
    return prod;

    Now I'm getting errors stating that I cannot use an instance object to access members of the Product class. I tried to resolve this issue by removing the line Product prod = new Models.Product(); and going to the Product class in ProjectA and adding the static keyword to the ID and Dept properties. I can now set values of the ID and Dept properties using the class name as shown below:

    Product.ID = unit.ID;
    Product.Dept =unit.Department;

    But the big problem now is I do not have the instance object of the Product class so I cannot return it and I get an error related to that. How do I return the Product class instance in this situation?

    C# help question tutorial

  • How To Return A Class With Static Members
    L Liagapi

    Suppose in my project I'm referencing another project as follows:

    using static ProjectA;

    Prior to using the static keyword in the using statement, one of my methods was able to create an instance object of a class called Products, set the values of its members, and return the instance object as shown below:

    Product prod = new Models.Product();
    prod.ID = unit.ID;
    prod.Dept =unit.Department;
    return prod;

    Now I'm getting errors saystating that I cannot use an instance object to access members of the Product class. I tried to resolve this by going to the Product class in ProjectA and added the static keyword to the ID and Dept properties. But the big problem now is I do not have the instance object of the Product class so I cannot return it and I get an error related to that. How do I return the Product class instance in this situation?

    C# help question tutorial

  • Generate an MVC Project Folder and Files Using Web API 2.2
    L Liagapi

    Is it possible to generate an MVC project folder and files using Web API 2.2? I'd like to know because I need to generate MVC project folder and files dynamically.

    ASP.NET asp-net json architecture question

  • AJAX Call To JSON File On Local Machine Failed With No Errors
    L Liagapi

    I am trying to access a json file on my local machine using XMLHttpRequest when a dropdownlist item is selected but it is not working. Basically when a user clicks a button with an id of GetTeam on my webpage, it will call the DisplayTeams function which will generate a dropdownlist and a div dynamically for displaying players' data. Once the dropdowlist is generated and the user clicks on one of the teams in the dropdownlist, the function DisplayPlayers will call the DisplayPlayersByTeam method to access my json file. It will then call the function RenderPlayersData to render players' data on the PlayersData div if the AJAX call is successful. I have successfully generated the dropdownlist but it appears the AJAX call is not working. Please point out why my code below is not working.

    function DisplayTeams(){
    var calendar = document.getElementById('DataScreen');
    calendar.innerHTML= '';
    calendar.innerHTML = '

    ' +
    '' +
    'Select A Team' +
    'Cavaliers' +
    'Bulls' +
    'Lakers' +
    'Warriors' +
    '' +
    '

    ' + '

    '
    }

    function DisplayPlayersByTeam(team){
    var ajaxObj = new XMLHttpRequest();

    ajaxObj.overrideMimeType("application/json");

    ajaxObj.open('GET','Teams/PlayersData.json', true);

    ajaxObj.onreadystatechange = function(){

    if(ajaxObj.readyState == 4 && ajaxObj.status == 200){
     var data = JSON.parse(ajaxObj.responseText); 
      
      RenderPlayersData(team); /\* This function will render players' data if AJAX is successful. \*/
    }else{
       alert("there is an error");
    }   
    

    }
    ajaxObj.send(null);
    }

    JavaScript sharepoint collaboration json help

  • Display Derived Objects In Swagger Example Values
    L Liagapi

    Sorry if this is not the correct forum for discussions on Swagger but I don't know which one is appropriate for it. I have a rest web api created in C# which returns a JSON response containing base objects and their derived objects. In Swagger response body I am able to see both the base objects and derived objects after applying the filters as explained in the post How do I include subclasses in Swagger API documentation using Swashbuckle? - Stack Overflow[^] However, I only see the base objects in the Example Values and not their derived objects. So suppose my JSON contains objects called Dog and Cat which inherit from the Animal object, then only the Animal object will show up in the Example Value but not the Dog or Cat object. Please show me how to modify Swagger Example Value to display base objects and their derived objects. Thanks.

    Web Development json tutorial question csharp com

  • Matching Percent Symbol Using REGEX
    L Liagapi

    It is now working. It was driving me nuts, after everything failed I decided to restart Visual Studio and it started working.

    C# regex help architecture question

  • Matching Percent Symbol Using REGEX
    L Liagapi

    Hi, thanks for your reply. I have updated my pattern by eliminating the back slash in front of the colon and semicolon as you have suggested. However, it still does not work. Below is the updated pattern

    pattern = escapedString + @":\s?\d+\W(\s?\w+)*\s?;?\s?";

    C# regex help architecture question

  • Matching Percent Symbol Using REGEX
    L Liagapi

    Hello, I am trying to match a substring which contains the percent symbol using REGEX W character but it does not seem to work. Below is what I have so far.

    string inputString = @"#Test{border-top:Solid blue 1px; border-bottom:1% solid black;}";
    string escapedString = Regex.Escape("border-bottom");
    string pattern = escapedString + @"\:\s?\d+\W(\s?\w+)*\;?\s?";
    Regex rgx = new Regex(pattern);
    Match match = rgx.Match(matchedCss);
    string matchedString = match.Value;
    Console.WriteLine(matchedString);
    Console.ReadLine();

    The REGEX pattern above should have matched the substring

    border-bottom:1% solid black;

    but for some reason it did not. Please help me resolve this problem, thanks in advance.

    C# regex help architecture question

  • Get Percentage Height To Work on Li Elements And Maintain Image Aspect Ratio Inside Li Elements
    L Liagapi

    I have a responsive web page where there are images inside a horizontal unordered list. I want my web page to shrink/stretch when the page resolution changes so I did not set the width or height of any page elements using pixels. Below are my media query and markup:

    media screen and (min-width: 320px) {
    html, body{width:100%;height:100%;}
    #banner{width:100%;height:10%; border:1px solid blue}
    #largeImage{width:100%;height:70%; border:1px solid blue}
    #picsContainer{width:100%;height:10%; border:1px solid blue}
    img{width:100%;height:auto}
    ul{list-style:none}
    ul li{width:10%;height:100%; display:inline-block; border:1px solid blue}
    footer{width:100%;height:10%;border:1px solid blue}
    }


    image

                *   ![image1](pic/img1.jpg)
                *   ![image2](pic/img2.jpg)
                *   ![image3](pic/img3.jpg)
                *   ![image4](pic/img4.jpg)
                *   ![image5](pic/img5.jpg)
                *   ![image6](pic/img6.jpg)
                
            
    
        
    
        
    
           Footer
    

    I have just two questions: 1 - How do I get height:100% to work on ul li elements without giving a pixel width to their parent or grand parent? 2 - How do I maintain aspect ratio for images inside li elements?

    Web Development html question mobile database architecture

  • SignalR Instant File Upload
    L Liagapi

    Hi Pete, yes the video description did say that SignalR was used but the video only shows the uploading and displaying of images but no code was shown. The name of the video is

    Real Time Image Uploading No Coding - SignalR

    C# json

  • SignalR Instant File Upload
    L Liagapi

    I've always thought that SignalR does not support the transfer of binary data and although one can convert an image into a base64 string and send it, Websocket which SignalR uses, has a size limit of 64K. So every post online related to sending an image via SignalR says it cannot be done and that Web API should be used instead for that purpose. Having said all that, I came across a Youtube video which shows a person uploading an image in one browser and then instantaneously displaying it in another browser. Can someone explain how this can be possible

    C# json

  • Pausing Reception of Data
    L Liagapi

    Hi all, suppose I've queried a data source and let's say 10 thousand records are supposed to come back. If I want to pause the reception of the data at a particular record and then resume the data reception on button click is there a way to do this using C#? Thanks in advance.

    C# csharp question career

  • Understanding IOC
    L Liagapi

    Hi thanks for replying. I meant to say a generic class that has virtual methods or methods that take generic types T.

    C# question

  • Understanding IOC
    L Liagapi

    I've recently read about the Inversion of Control (IOC) principle and I have a few questions I'd like to have answered. I've read that in order to implement the principle of IOC, one must not define a class and pass in concrete objects as its constructor's parameters but one must instead use interfaces as its constructor's parameters. My first question is can I implement IOC by defining a class with virtual classes as its constructor's parameters instead of interfaces. After all the whole reason behind using interfaces is to decouple the class from its dependencies and virtual classes can pretty much do that. My second question is can I use abstract classes as parameters instead of interfaces. Thanks in advance for your reply.

    C# question

  • Understanding IOC
    L Liagapi

    I've recently read about the Inversion of Control (IOC) principle and I have a few questions I'd like to have answered. I've read that in order to implement the principle of IOC, one must not define a class and pass in concrete objects as its constructor's parameters but one must instead use interfaces as its constructor's parameters. My first question is can I implement IOC by defining a class with virtual classes as its constructor's parameters instead of interfaces. After all the whole reason behind using interfaces is to decouple the class from its dependencies and virtual classes can pretty much do that. My second question is can I use abstract classes as the parameters instead of interfaces. Thanks in advance for your reply.

    C# question

  • Array Length Is Greater Than Number Of Array Items
    L Liagapi

    I have a table element containing 3 rows and 3 columns. In each row are 3 input elements and each element has an ID like below:

    -----------------------------------
    -- R1C1 -- | -- R1C2 -- | -- R1C3

    -- R2C1 -- | -- R2C2 -- | -- R2C3

    -- R3C1 -- | -- R3C2 -- | -- R3C3

    Users can enter a number into each input element then click submit when done. An array is used to store values of input elements in each row, so there are a total of three arrays used. I'm trying to use loops to insert the value of each input element in a given row into a specific position in an array. The problem I'm having is that even if there are fewer than 3 numbers inserted into an array, it will show that its length is 3. Below is my code

    var Row1 = []; var Row2 = []; var Row3 = [];
    var r; var textbox;

    function InsertNumbersIntoArrays(){

    for(var a = 1; a< 4; a++){
    r = 'Row' + a;

    for(var b = 1; b< 4; b++){
    
      textbox = document.getElementById("R"+ a + "C" + b).value;  
    
      for(var i= 0; i<3; i++){
         if(textbox.length != 0){
           eval(r).splice(i,0,textbox.value);
         } 
      }
    
    } 
    
     alert("length of array " + r + " is " + eval(r).length);
    

    }
    }

    JavaScript data-structures help

  • Array Length Is Greater Than Number Of Array Items
    L Liagapi

    I have a table element containing 3 rows and 3 columns. In each row are 3 input elements and each element has an ID like below:

    -----------------------------------
    -- R1C1 -- | -- R1C2 -- | -- R1C3

    -- R2C1 -- | -- R2C2 -- | -- R2C3

    -- R3C1 -- | -- R3C2 -- | -- R3C3

    Users can enter a number into each input element then click submit when done. An array is used to store values of input elements in each row, so there are a total of three arrays used. I'm trying to use loops to insert the value of each input element in a given row into a specific position in an array. The problem I'm having is that even if there are fewer than 3 numbers inserted into an array, it will show that its length is 3. Below is my code

    var Row1 = []; var Row2 = []; var Row3 = [];
    var r; var textbox;

    function InsertNumbersIntoArrays(){

    for(var a = 1; a< 4; a++){
    r = 'Row' + a;

    for(var b = 1; b< 4; b++){
      textbox = document.getElementById("R"+ a + "C" + b).value;   
      for(var i= 0; i<3; i++){
         if(textbox.length != 0){
           eval(r).splice(i,0,textbox.value);
         } 
      }
    } 
     alert("length of array " + r + " is " + eval(r).length);
    

    }
    }

    JavaScript data-structures help

  • Returning JSON From RESTful WCF
    L Liagapi

    Thank you so much for your reply. I can now see that the data I received from the AJAX call is indeed JSON.

    C# csharp javascript wcf json

  • Returning JSON From RESTful WCF
    L Liagapi

    I created a RESTful WCF Service and made sure that the data returned from it is of type JSON by setting its ResponseFormat property equal to WebMessageFormat.Json in my WCF Service as follows:

    ResponseFormat = WebMessageFormat.Json

    I checked to ensure that data returned from the WCF Service is indeed JSON by using Fiddler. What I don't understand is if the return type of the data is JSON then why do I need to convert it to a JSON string using JSON.stringify() in my jQuery AJAX call.

    C# csharp javascript wcf json
  • Login

  • Don't have an account? Register

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