Thursday, February 17, 2011

Lesson 4

Thanks to those that have turned in there assignment for lesson 4.  Any comments on this assignment?  John has an idea of why I was having a problem when I deactivated the autoPostBack property for one of the PullDown controls.  John, could you  post that.  I think you have it right.

7 comments:

  1. I was looking in to the "double table" issue (the table being displayed twice), and think I may have figured out the difference between a "postback" and an "autopostback".

    I noticed that when I disabled AutoPostBack on the DropDownList control, that the event code still fired. I'm guessing it is called because a "changed" value was submitted for that control, and that's the event that's being tracked. For example, I set AutoPostBack to false for both DDL's, then changed BOTH values, and then pressed "Calculate Totals" and got three tables! Versus when I change neither value, and just hit Calculate, I get only one table.

    My Solution...
    I commented out the drawTable() call follows:

    protected void drpRows_SelectedIndexChanged(object sender, EventArgs e)
    {
    // drawTable(); // uncomment when AutoPostBack is enabled (comment out when disabled, as something else will cause the table to draw.)
    }


    I'm also wondering if an approach might be to move the drawTable to outside the "if (!IsPostback)", and leave drawTable out of all the other functions:


    if (!IsPostBack)
    {
    for (var i = 1; i < 11; i++)
    {
    drpRows.Items.Add(new ListItem(i.ToString()));
    drpColumns.Items.Add(new ListItem(i.ToString()));
    }

    // Set default value to 5x5 table
    drpRows.SelectedIndex = 4;
    drpColumns.SelectedIndex = 4;
    }

    drawTable();

    ReplyDelete
  2. Terry,
    My webpages run when I am in Visual Studio but what do I do to run my webpages outside of VS? I wanted to see my Lesson 4 & 5 but realized that I only know how to do it in VS.

    Thanks!

    ReplyDelete
  3. Hi Carmen,
    What operating system are you running - XP, Windows 7? You'll need to setup Internet Information Services (IIS) to serve up the pages. Let me know which OS, and I'll send you some screen-pictures on how to point IIS to where your files are and let you see the webpages at http://localhost, instead of having to launch VS.
    -John

    ReplyDelete
  4. Hi John,
    This message board is not the best huh? I had responded to your post but I guess I must have not done it correctly.

    Anyway, I use Windows 7 on my laptop but I do practice at work which we use XP. If your instructions work for both, that will be great. Thanks!
    clg

    ReplyDelete
  5. Hi Carmen,

    We will have a session on deploying web sites in a few weeks and we will "turn in" our assignments by deploying them to an external server. John is right. When you run your sites from VS it acts as your web server and allows you to debug your code as it runs. When it is deployed there needs to be a server to run the site. XP and 7 have built in servers that you can use. You just have to make sure it is running and put the files in the right place.

    Terry

    ReplyDelete
  6. Oops, eBlogger doesn't like less than and greater than symbols...
    <system.web>
    <customErrors mode="Off" />
    </system.web>

    ReplyDelete
  7. Hi Carmen,

    Windows 7:
    I'm sure the future lesson will have a better way to do this, as I used "brute force" rather than expertise...
    By "brute force" I mean that I just copied it there, and then kept changing code, based on the errors the IIS server kept coughing up.

    1. Changed the Security on the C:\inetpub\wwwroot folder for "Users" to have "Modify" permissions.

    2. Copied (DO NOT "MOVE") all my files (including web.config) into C:\inetpub\wwwroot

    3. Renamed iisstart.htm to iisstart.old.htm to prevent it from launching (and letting my default.aspx start instead).

    4. Change the system.web section to ONLY read as follows:
    *** See prior post ***



    5. In the Default.aspx.cs, and my lesson6.aspx.cs files I commented out System.Linq:
    //using System.Linq;

    Then I could type in "localhost" in my browser, or enter the IP address of my computer in to any other computer and launch my homework assignment - independant of Visual Studio.

    Why modify the Web.config file, or remove Linq? I have no clue, I expect to read about it soon...

    ReplyDelete