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
A

ASPnoob

@ASPnoob
About
Posts
302
Topics
171
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Adding Objects To Session
    A ASPnoob

    Thanks for replying your suggestion is very helpful.

    ASP.NET help

  • Adding Objects To Session
    A ASPnoob

    I have a list called List < Accounts > where I can add customers' info after supplying the needed data and clicking the Add button on my webform. To persist my data between postbacks I stored my data in a session variable then retrieve them from that session variable later on. The problem is the session variable only shows one account even though I added multiple accounts. The folloewng is my code.

    List accts = new List();

    protected void btnShowAccountDetails_Click(object sender, EventArgs e)
    {
    StringBuilder acctDetails = new StringBuilder();

    if (Session\["acctObjects"\] != null)
    accts = (List)Session\["acctObjects"\];
    
    foreach(Account acct in accts)
    {
     acctDetails.Append("ID: "+ acct.Name + " Account ID: " + acct.AccountID + "<br/>");
    }   
    
    litCtrShowAccountDetails.Text = acctDetails.ToString();
    

    }

    protected void btnAddAcctount_Click(object sender, EventArgs e)
    {
    Account acct = new Account();
    StringBuilder acctDetails = new StringBuilder();

    if (!String.IsNullOrEmpty(txtName.Text))
    {
    acct.Name = txtName.Text;	
    }
    else
    {
    //Display Error message
    ScriptManager.RegisterStartupScript(this, GetType(), "EmptyName", "EmptyNameAlert();", true);
    }
    
    if (!String.IsNullOrEmpty(txtAccountID.Text))
    {
    acct.AccountID = txtAccountID.Text;	
    }
    else
    {
    //Display Error message
    ScriptManager.RegisterStartupScript(this, GetType(), "EmptytAccountID", "EmptytAccountIDAlert();", true);
    }
    
    accts.Add(acct);
    Session\["acctObjects"\] = accts;
    

    }

    Please help me resolve this issue, thanks in advance.

    ASP.NET help

  • Getting Invalid Token Error After Adding Runat = Server
    A ASPnoob

    Hi all, I am getting the error "Invalid token ';' in class, struct, or interface member declaration" after adding runat = "server" to html elements in my aspx.designer.cs files. I added runat = server to html elements so that they can be manipulated dynamically from codebehind. I've looked online to see why I'm getting the error but I have yet to find anything that is remotely close to my situation. Any help will be greatly appreciated, thanks.

    ASP.NET help html sysadmin

  • Get Content of a Clicked Div in Iframe
    A ASPnoob

    Hi all, I am trying to create a web editor using an Iframe. So basically users can open up a page they want to edit in the Iframe and edit away. I want to be able to grab the content of any element of a page and then do what I need to with it. I ran into some problems when there are elements embedded in other elements such as a div with children each having no id or class attributes. I tried to solve this problem by first identifying which element was clicked and give it a temporary id if id did not already have one. Then using the new id get the content (I'm trying to get the text). I tried to implement that idea using the code below but it did not work.

    $('#myiframe').load(function () { //load iframe
    $(this).contents().find("body").on('click', function (event) {
    var a = event.target.tagName;
    var divContent = $("#myiframe").contents().find(a);

     $(divContent).click(function (e) {                                         
         var ClickedElementID = e.target.id;   // Get id of target element
         if (ClickedElementID == "") {         // Check if an element has an id
            e.target.attr('id', 'tempID');     // If target element has no id add one
            var  myText = $('#tempID').text(); // Get text using tempID
            $('#tempID').removeAttr('id');     // Remove temporary id
         }
         else {
           
           var myText = $(ClickedElementID.text()) // Get text
         }         
      });      
    }
    

    }

    Please help me make the code above work as I intended, thanks in advance.

    JavaScript help hardware

  • Data at the root level is invalid. Line 1, position 1.
    A ASPnoob

    Hi, thanks for replying. You got me thinking for a minute there with your question

    "JSON is XML, is it not?"

    According to json.org JSON is not XML, it's an alternative to XML. Also the website

    http://searchwindevelopment.techtarget.com/definition/JSON-Javascript-Object-Notation

    says the following:

    "JSON was originally based on the Javascript programming language and was introduced as the page scripting language for the Netscape Navigator Web browser"

    C# visual-studio help csharp html sysadmin

  • Data at the root level is invalid. Line 1, position 1.
    A ASPnoob

    Hi, thanks for replying. I validated the webconfig file and it is actually valid. It turns out the problem was in the url in my ajax. I copied and paste the webservice url from Visual Studio and it appears a couple of letters were automatically tacked onto the url between the webservice name and the webmethod name. Once I removed the extra letters everything worked fine.

    C# visual-studio help csharp html sysadmin

  • Data at the root level is invalid. Line 1, position 1.
    A ASPnoob

    Hi, thanks for responding. I am not reading or writing any XML. In fact even after removing all the code in the webmethod of my webservice except for the return statement

    return "Success!";

    I still get the same error.

    C# visual-studio help csharp html sysadmin

  • Data at the root level is invalid. Line 1, position 1.
    A ASPnoob

    Hi all, I have a web service that used to work but stopped working when I migrated to a new computer. The new computer comes with Windows 8.1 and IIS Express. I made sure that I got everything I need by selecting every option under IIS. I installed the same version of Visual studio (VS 2012) on the new machine and tried to run the same web app I had in the old machine. When I click a button which makes a call to my web service, nothing happens. I found out through Fidler2 that the problem was

    "Data at the root level is invalid. Line 1, position 1."

    I have searched online but none matched my situation. Basically all I'm trying to do is send text from a regular html page in the form of JSON to the web service. Then the web service will modify a text file on the server using the text it received. I know the code in the web service works because I called it directly in Visual Studio and it worked fine. Please suggest a way to fix this problem, thanks in advance

    C# visual-studio help csharp html sysadmin

  • System.Web.HttpContext cannot be serialized because it does not have a parameterless constructor.
    A ASPnoob

    Hi all, I am attempting to save images from the desktop in a folder on the server using the following web service code:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.Services;
    using System.IO;
    using System.Drawing;
    using System.Drawing.Imaging;

    namespace MultipleImageUploadDemo
    {
    /// /// Summary description for SaveImageService
    ///
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
    [System.Web.Script.Services.ScriptService]
    public class SaveImageService : System.Web.Services.WebService
    {

        public SaveImageService()
        {
        }      
    
        \[WebMethod\]
        public void ProcessRequest(HttpContext context)
        {
            if (context.Request.Files.Count > 0)
            {
                HttpFileCollection files = context.Request.Files;
                foreach (string key in files)
                {
                    HttpPostedFile file = files\[key\];
                    string fileName = file.FileName;
                    fileName = context.Server.MapPath("~/Upload/" + fileName);
                    file.SaveAs(fileName);
                }
            }
            context.Response.ContentType = "image/JPEG";
            context.Response.Write("File(s) uploaded successfully!");
        }
       
    }  
    

    }

    I got the following error when I try to run the web service:

    System.Web.HttpContext cannot be serialized because it does not have a parameterless constructor.

    I looked up the error message online and many posts I came across suggest that I create a parameterless constructor in my web service class which is responsible for deserializing the binary data. I tried that as you can see in my code, but I still get the same error message. If you think there is something else I should try please help. Thanks in advance for your help.

    C# csharp help asp-net linq graphics

  • Uncertain on What to Use as Foreign Key of a Table
    A ASPnoob

    Hi, thanks for responding. You said "calling it userstable is redundant", that was a typo.

    Database database career design xml help

  • Uncertain on What to Use as Foreign Key of a Table
    A ASPnoob

    Hi all, I am trying to design a database to hold data for a job portal. Basically I have a database called SiteUsers which contains five tables (UsersTable, JobSeekersTable, ResumesTable, EmployersTable, and JobsTable). The following are the table schema for UsersTable, ResumesTable, and JobsTable. The UsersTable has a Primary Key (PK) of UserID and a Foreign Key (FK) of Username. The ResumesTable has a PK of ResumeID and the JobsTable has a PK of JobID. The JobSeekersTable has a PK of Username. The EmployersTable has a PK of Username. The question I have is should the JobSeekersTable FK also be Username, or ResumeID, or a composite of Username and ResumeID. I think that the FK should be Username because it's unique but because it's not the primary key of the JobsTable I am uncertain. Also I did not want to use ResumeID as the FK in the JobSeekersTable because although it will be unique a job seeker can have more than one resume. Whether you agree or disagree with my assumption that Username should be the PK and FK in the JobSeekersTable, please elaborate your answer . Thanks in advance for your help.

    Database database career design xml help

  • Retrieve Data Using Comma Separated List
    A ASPnoob

    Hi all, Suppose I have a database table named JobsTable and among the fields in the table are JobDescriptions, and JobTitle. How would I write my Where clause if users can get all the JobTitle where the JobDescriptions field contains any word in the comma separated list they entered? I tried the Like keyword but it is not doing what I want. Thanks in advance for your help.

    Database database help question

  • Upload and Save Image Using Webservice
    A ASPnoob

    Hi, thanks for responding. The web service is not registered in the Scriptmanager control and there is no ASXP page.

    C# help csharp javascript asp-net linq

  • Upload and Save Image Using Webservice
    A ASPnoob

    The web service is not registered in the scriptmanager control and there is no aspx page.

    C# help csharp javascript asp-net linq

  • Upload and Save Image Using Webservice
    A ASPnoob

    Hi all, I have a web page that allows users to drag an image from their desktop on to a box that had been designated as a droppable box. Once the image is dropped it will be sent to a web service to be saved in a folder on the server. The following is the Javascript I'm using to send the image from the frontend to the webservice.

    function ImageUpload(file) {
    xhr = new XMLHttpRequest();
    xhr.open('post', 'SaveImageService.asmx', true);
    xhr.setRequestHeader('Content-Type', "multipart/form-Data");
    xhr.setRequestHeader('X-File-Name', file.fileName);
    xhr.setRequestHeader('X-File-Size', file.fileSize);
    xhr.setRequestHeader('X-File-type', file.fileType);
    xhr.send(file);
    };

    I am using the following code in my web service to save the posted image in a folder called Images. I'm not certain if the project folder name should be included as part of the folder path when I specify where to save the uploaded images. I tried including and excluding the project folder name but it didn't help.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Services;
    using System.IO;
    using System.Drawing;
    using System.Drawing.Imaging;

    namespace ImageUpload
    {
    /// /// Summary description for SaveImageService
    ///
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
    [System.Web.Script.Services.ScriptService]
    public class SaveImageService : System.Web.Services.WebService
    {

        \[WebMethod\]
        public void SaveImage()
        {
            var httpRequest = HttpContext.Current.Request;
            foreach (string file in httpRequest.Files)
            {
                var postedFile = httpRequest.Files\[file\];
                var filePath = HttpContext.Current.Server.MapPath("~/Images/" + postedFile.FileName);
                postedFile.SaveAs(filePath);
            }
        }
    }
    

    }

    I am getting response status of 500 internal server error. Please look at the code above and point out any problem you see. Thanks in advance for your help.

    C# help csharp javascript asp-net linq

  • Get Page Markup
    A ASPnoob

    Hi all, if I want to dynamically grab the markup of my page after making changes to the DOM using javascript how would I go about it. I know that there are tools out there for viewing the DOM of a page after it has been modified using javascript but I would like to actually grab the new DOM and save it dynamically using code. Thanks in advance for your help.

    Web Development html javascript tools help

  • Search and Retrieving String
    A ASPnoob

    Hi all, suppose I have a text file that contains hundreds of entries with each entry surrounded by an opening @ symbol and a closing /@ symbol, and each entry is separated from the next by a blank line like below:

    @ Entry Date: 6/01/2014, Time:1000 AM EST, UserID: U123456789,

    Input: Blah Blah Blah ggogo klj'm' lkkjhgy 8oiui9in lrxutxcuucx cufcfx rdutrrrd dxddzsz, /@

    @ Entry Date: 7/01/2014, Time:1000 AM EST, UserID: U134233569,

    Input: tgvggv jjjn tsewa klj'm' lkkjhgy ojgi yvytf j;jn ij[ji tfzdy , /@

    If I want to get all the inputs of a particular user with a certain UserID, how would I go about doing that? I know I have to use string.contain method to check if a certain UserID exist and if it does, use the characters "@", "/@", "Input:", and "," as the delimiters to refine the search. But I'm not real clear on how to go about it. Any suggestions will be greatly appreciated, thanks in advance.

    C# tutorial question

  • Populating Input Fields Using Button UIs
    A ASPnoob

    Hi, thanks for replying. Your code works like a charm.

    JavaScript javascript html tools help

  • Populating Input Fields Using Button UIs
    A ASPnoob

    Hi all, I have a web app that has a display box and button UIs for typing numbers (0 through 9) into the display box. There is one button that when clicked generates multiple input fields. My problem is that I can enter numbers into the first input field by clicking the numbered buttons and by typing numbers using the keyboard. Numbers can only be entered into other input fields using the keyboard. Any attempt to use the numbered buttons to enter numbers into other input fields will cause the focus to return back to the first input field. Below are my markups and jquery

    <body>

    <script type="text/javascript">
    $(document).ready(function () {

    if ($('#box1').click())
    {      
        $(".BTN").click(function () {
            if ($.isNumeric($(this).html())){
                $("#box1").val($("#box1").val() + $(this).html());           
        }});    
             
         }
         else
             if ($('#box2').click())
             {                  
                 $(".BTN").click(function () {
                     if ($.isNumeric($(this).html())) {
                         $("#box2").val($("#box2").val() + $(this).html());
                     }
                         
                     });                 
             }
             else
                 if ($('#box3').click())
                 {
                     $(".BTN").click(function () {
                         if ($.isNumeric($(this).html())) {
                             $("#box3").val($("#box3").val() + $(this).html());    
                         }});
                 }
    
        $("#functs").click(function () {
         
       document.getElementById("myOutputs").innerHTML =
        ""
       + ""
            + ""
       + ""
            + ""
       + ""
            + ""
       + "
    

    <input type='text' id='box1'/>

    <input type='text' id='box2'/>

    <input type='text' id='box3'/>

    ";
    document.getElementById('box1').tabIndex = "1";
    document.getElementById('box2').tabIndex = "2";
    document.getElementById('box3').tabIndex = "3";
    });
    }

    Please explain why the code above is giving me the problems I've stated, thanks in advance.

    JavaScript javascript html tools help

  • Adding Var Object to An Array Dynamically
    A ASPnoob

    Hi thanks for replying, I did not realize that Microsft Word auto-correct changed the var keywords to vary. I was able to get the code to work with your help.

    JavaScript data-structures
  • Login

  • Don't have an account? Register

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