Violet_82 89 Posting Whiz in Training

OK, I tried that but it wasn't successful as I'm getting an error now. This is what I have done. In the Site.master.aspx.cs I have this code:

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using System.IO;



public partial class Site : System.Web.UI.MasterPage
{

  public void ActiveClass(string whatPage) {
        string PageName = whatPage;
        switch (PageName) {
        case "HomeLink":
        HomeLink.CssClass = "active";
        break;

        case "AboutLink":
        AboutLink.CssClass = "active";
        break;

        case "OPLink":
        OPLink.CssClass = "active";
        break;

        }
    }
}

In my content pages I call the function in this fashion:
Home.aspx.cs:

public partial class Home : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Site master = new Site();
        master.ActiveClass("HomeLink");
    }
}

About.aspx.cs

...
public partial class About : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Site master = new Site();
        master.ActiveClass("AboutLink");
    }
}

Other_projects.aspx.cs

...
public partial class Other_projects : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Site master = new Site();
        master.ActiveClass("OPLink");
    }
}

When I run the application, I don't get any error in the compiler but the webpage returns one of those Server error:

Object reference not set to an instance of an object.
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.NullReferenceException: Object reference not set …
Violet_82 89 Posting Whiz in Training

OK, thanks, let me have a go then and see if it works :-). Thanks, I will post back

Violet_82 89 Posting Whiz in Training

OK so, let's see if I got this right:
- replace my anchor links with:

<asp:HyperLink ID="HomeLink" runat="server">Home</asp:HyperLink>
<asp:HyperLink ID="AboutLink" runat="server">About</asp:HyperLink>
<asp:HyperLink ID="OPLink" runat="server">Other projects</asp:HyperLink>

in the master page (where do I put the target page within an asp link by the way?)
-in the master page aspx.cs create a function that adds the class active to the navigation, something like:

public void ActiveClass(string whatPage){
    string PageName = whatPage;
    switch(PageName){

        case "Home"
        HomeLink.CssClass = "active";
        break;

        case "AboutLink"
        AboutLink.CssClass = "active";
        break;

        case "OPLink"
        OPLink.CssClass = "active";
        break;
    }
}

-in the pages in question call the function defined in the master page like so:

From the Home.aspx:
ActiveClass("Home");
From the About.aspx
ActiveClass("AboutLink");
From the Other_projects.aspx
ActiveClass("OPLink");

Violet_82 89 Posting Whiz in Training

"I'd add a public method that adds the class, instead of accessing the controls." (sorry didn't let me quote for some strange reasons)

Thanks, but I presume that even if I add a public method I still need to somewhow figure out which page to add the active class to, as JorgeM has pointed out.

I mean I like the other approach as it seems less complicated but only half way implementing that I get an error as I metioned in my previous post:
Type 'System.Web.UI.WebControls.HiddenField' doesn't have a public property named 'ClientIDMode'
and
Validation (ASP.NET):Attribute 'ClientIDMode'is not a valid attribute of element 'HiddenField'
That's without having added the clientside js. ANy idea why I'm getting that?

Violet_82 89 Posting Whiz in Training

thanks for that. OK a few things.I looked up the code you used but I'm not sure I understand the whole thing.
ClientIDMode="Static" not sure what it does, other than returning an ID presumably
hndPageName.Value = System.IO.Path.GetFileNameWithoutExtension(Request.ServerVariables["SCRIPT_NAME"]); with this, do I need to replace SCRIPT_NAME with what? So basically this method is supposed to return the file name of whatever string you pass as an argument - from what I read - so what's that Request.ServerVariables["SCRIPT_NAME"] doing? What is it getting?
I have implemented the first part:
<asp:HiddenField ID="hdnnPageName" ClientIDMode="Static" runat="server /"> at the bottom of the Site.master page and then in the code behind of that page I have

protected void Page_Load(object sender, EventArgs e){
    hdnPageName.Value = System.IO.Path.GetFileNameWithoutExtension(Request.ServerVariables["SCRIPT_NAME"]);
}

and added the IO name space (not sure if this was needed or not) using System.IO;
but when I run it I get an error:
Type 'System.Web.UI.WebControls.HiddenField' doesn't have a public property named 'ClientIDMode'

In general though, with your code you're essentially trying to generate an id whose value will be the page name without the aspx extension, correct, or have I got things wrong?
$('#' + pageName).addClass('active'); this line in jquery: say we are on the home page (which by the way will be Home.aspx and not home.html, sorry my mistake) what value would pageName assume? I take "Home"? But this $('#' + pageName).addClass('active'); looks for an element with an ID of Home and adds a class of active to it? Sorry problably I completely …

Violet_82 89 Posting Whiz in Training

OK will look into that then, thanks

Violet_82 89 Posting Whiz in Training

Hello guys, I wonder if you can help. I've got an existing site that I want to "convert" to an ASP.NET one and I gave a good read at the master template tutorial suggested in another thread, but I'm having a few problems deciding what goes in the master page and what doesn't. On the general level it is obvious of course, the elements common to all the pages go in the master page, the rest is out. In my case I've got the following problem: the navigation on the home page has the following markup:

<div class="navigation">
    <a href="home.html" class="active">Home</a>
    <a href="about.html">About</a>
    <a href="other_projects.html">Other projects</a>
    <div class="clear"></div>             
</div>

In my asp.net master page though, I decided not to include the navigation elements:

<div class="navigation">
    <asp:ContentPlaceHolder ID="navigationPlaceholder" runat="server">
    </asp:ContentPlaceHolder>
    <div class="clear"></div> 
</div>

and to leave that to each page.Now, you could argue that the navigation is a common element across the site, and in fact it is, but the markup will be slightly different for each page: we saw the home page above, here are the two other pages. About page:

<div class="navigation">
    <a href="home.html">Home</a>
    <a href="about.html" class="active">About</a>
    <a href="other_projects.html">Other projects</a>
    <div class="clear"></div>             
</div>

Other project page:

<div class="navigation">
                <a href="home.html">Home</a>
                <a href="about.html">About</a>
                <a href="other_projects.html" class="active">Other projects</a>
                <div class="clear"></div>             
            </div>

As you can see the difference is the active class and where it sits on each page, that's why I did it this way. Is it right, wrong? I mean if I had to include the …

Violet_82 89 Posting Whiz in Training

Ahem, so with this Azure, you say, I can upload my asp.net application on to the cloud for free and access it as I would access a normal website?

Violet_82 89 Posting Whiz in Training

cool thanks, I will give it a go then

Violet_82 89 Posting Whiz in Training

thanks guys, I did it eventually and not used the custom validator (as I couldn't get that to work), I managed to do everything with the range validator and the required field

Violet_82 89 Posting Whiz in Training

Hi all, I was having a look at this tutorial on asp.net master pages http://www.asp.net/web-forms/overview/older-versions-getting-started/master-pages/creating-a-site-wide-layout-using-master-pages-cs but alas I have to apply this the other way around: as you would normally expect, you'd create the master page first and then content pages, but I have content pages and now I have to create a master page and link it to the content pages. Is this doable or do I have to create a master page first and then content pages? Unfortunately when I begun to work to my asp.net current project I didn't even know that master pages existed!

Violet_82 89 Posting Whiz in Training

OK thanks, and obviously somebody with a windows server...strange but neither my internet provider nor the company that hosts my website have windows servers...

Violet_82 89 Posting Whiz in Training

Hi all, I was just wondering, how do I go about making an asp.net application accessible on the internet? The application is also linked to a SQL database (created in visual studio). I have got server space available but I'm not sure where the sql database needs to be copied on etc. A quick search on the net brought up things like "deploying the site on azure" which I have absolutely no idea what it means, I just want to upload the application on a server I own - well, rather the company I work for own. What would I need to ask the support team for this to happen?
thanks

Violet_82 89 Posting Whiz in Training

Thanks but I still have problems with the validation, this thing is really doing my head, lol. OK so here is the code, as it might be easier and clear any confusion:
Default.aspx:

<div class="control-group">        
<label class="control-label" for="week1">Week ending</label>
<div class="controls">
<!--<input type="text" id="week" runat="server">-->
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<asp:TextBox ID="txtStartDate" runat="server"></asp:TextBox>
<asp:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtStartDate" Format="dd/MM/yyyy">
</asp:CalendarExtender>
<asp:CustomValidator ID="CustomValidator1" OnServerValidate="CheckString" runat="server" ErrorMessage="Needs to be a dd/mm/yyyy string" ControlToValidate="txtStartDate"></asp:CustomValidator>
</div>

</div>           
<div class="buttons">
<input id="Submit1" type="submit" value="Submit" runat="server"  onserverclick="submitData"/>
<input id="Submit2" type="submit" value="Reset" runat="server" onserverclick="clearData"/>
<input id="Submit3" type="submit" value="Empty database" runat="server" onserverclick="clearTable"/>
</div>

This is where I added the customValidator.
Now the Default.aspx.cs
As you said, I added the above code at the top of the submitData method although I am not sure what goes in it, but anyway then I attempted some validation inside the CheckString method at the bottom: I created a string variable and assigned to it the text of the field I want to validate: if it's empty then e.isValid is false, but I can't get it to work - I've probably done something stupid just for a change.

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Web.UI.WebControls;
using System.Windows.Forms;//allegedly for messageBox

public partial class _Default : System.Web.UI.Page 
{
private SqlCommand sqlCmd;
private SqlConnection hookUp;
private string strInsert;
private const decimal WRKHRS = 37.5M;
private decimal HrsWorked;
private decimal Overtime;

protected void submitData(object sender, EventArgs …
Violet_82 89 Posting Whiz in Training

OK thanks, so that, I suppose, needs to be done after the validation has been done to check whether the validation has been passed, but how do I kick the validation off in the first place? As I said above the customValidator has this handler OnServerValidate="CheckString" and this is the method

protected void CheckString(object sender, ServerValidateEventArgs e){
MessageBox.Show("function called");
}

so I would have thought that was enough to get the function to run, but it doesn't. Does it mean that I need to kick things off from the submit button (it would seem more logical), but how since the submit button already has one event handler <input id="Submit1" type"submit" value="submit" runat="server" onserverclick="SubmitData">?
thanks

Violet_82 89 Posting Whiz in Training

Er, more importantly, I was thinking to how to trigger the validation. Let me explain. At the moment I have an html button that has an onserverclick="submitData" which calls the submitData function that has all the code for inserting stuff into the database: <input id="Submit1" type"submit" value="submit" runat="server" onserverclick="SubmitData">. In my aspx file I have inserted a customValidator controller, assigned an event handler to it like so <asp:CustomValidator ID="CustomValidator1" OnServerValidate="CheckString" runat="server" ErrorMessage="bla bla bla" ControlToValidate="txtStartDate"></asp:CustomValidator>, and in my code behind the CheckString function will contain the validation

protected void CheckString(object sender, ServerValidateEventArgs e){
MessageBox.Show("function called");
}

So I submitted the form but the CheckString function didn't get called, so my question is, how do I call that function? Do I call it also from the submit button adding it in the event handler like so
<input id="Submit1" type"submit" value="submit" runat="server" onserverclick="SubmitData, CheckString">?
thanks

Violet_82 89 Posting Whiz in Training

Thanks guys, so just to clear up this date picker thingy: I got it to work finally, and now I am looking at the validation. Since the field cannot be empty and I need the value to be in a certain format, I will use the custom validator. In terms of how to validate (I'm talking about the actual functions to use) I discovered this calendar has this handler "OnClientDateSelectionChanged" that I could use. Making sure the box isn't empty should be straightforward (I think it's a good time to say that I've never done validation before), as I could have a function that does that, like

private void checkField(object sender, EventArgs e){
    if(txtStartDate.Value==""){
    //how do I show an error message?
    }
}

but I'm not sure how to show an error message: I mean is it a message that sits in the page and gets shown/hidden as needed?
Then, to parse the string, do I need a regular expression (god help me!)?
cheers

Violet_82 89 Posting Whiz in Training

@pritaeas, sorry just to pick up on something you've said earlier:
To validate a data type use the CompareValidator.
I had a look at the compareValidator but it looks like it allows you to compare 2 separate fields, not just one. What I mean is, say you have 2 input fields where you are asked to insert the password and to confirm it, then you can use that validator to compare the two fields. But can it alse be used to validate one field like in my case (I need to validate the date inserted using the date picker)
thanks

Violet_82 89 Posting Whiz in Training

Um...I am not that keen to learn regex...that's why I was asking about using more than one validator ont he same element...will see anyway, tackling the date picker now

Violet_82 89 Posting Whiz in Training

thanks I will have a look at this!

Violet_82 89 Posting Whiz in Training

No problem, no need to be sorry :-). OK so I'll have a look at all that then and will post back if I get stuck. Thanks for your help

Violet_82 89 Posting Whiz in Training

OK thanks, yep I've read already a beginner book, ASP.NET 3.5 A beginners Guide by William B. Sanders, as I think I said somewhere in another post, but funnily enough there were never multiple pages in the examples :-)!

Violet_82 89 Posting Whiz in Training

OK thanks

You could choose to use a CustomValidator and do all those checks in code.

Now, say that for whatever reason I wouldn't want to use a customValidator, you said I could use as many validators as I want to, so theoretically, I could have both the range validator and the required field one with 2 separate error messages? I had a quick look at the custom validator, but it would appear that you have to write all the validation code yourself, which isn't necessarily a problem but I suppose I will have to find out how c# deals with strings, integers and empty fields.

I also had a look at the calendar: it's good but the one inbuilt in visual (the link to microsoft) is a calendar and not a date picker as such, so I would have to have a calendar displayed on the page all the time which might not be the best thing in my case. The other one seems more promising https://ajaxcontroltoolkit.codeplex.com/wikipage?title=Displaying%20a%20Simple%20Popup%20Calendar&referringTitle=Calendar%20Control and it displays a calendar when you click on the input field, so I may download and use that (I suppose it doesn't even require any database change because the date will be the value of the input field and the current code for populating the sql database should work)

Violet_82 89 Posting Whiz in Training

Thanks.

you'll want to develop the code on your own rather than using a web or html control.

You mean you can develop your own controls?

Violet_82 89 Posting Whiz in Training

Thanks.

Is there a specific reason you haven't used a DateTimePicker?

I suppose I had no idea there was one, sorry. Does it involve a lot of changes in code/C#/SQ? I just checked in the toolbox, but there is no DateTimePicker, where do I find it?

For an empty field you can use the RequiredFieldValidator. You can add as many validators to a field as you please.

Right, I had a look at all those inbuilt validation tools already, and I did actually add the range validator only, but since I then needed another one to make sure that the input was only a number, and the field not empty, I thought it was impossible to do with the inbuilt tools. SO just to summarize then: for the hours worked, I can add the range validation + the RequiredField and what about the fact that the input can only be a number (or is that included in the range validation)?
thanks

Violet_82 89 Posting Whiz in Training

Hello guys,
since I have now effectively completed my first asp.net application (it's a very basic application where people...ahem, where I can record overtime) I was wondering what the best way is to add some validation. The page which allows you to upload the details needed (date, hours worked and comments) is very simple but two of the fields (date and hours worked)need to be validated. Being as I have many times repeated at the very beginning of my asp.net/visual studio/C#/SQL trip, I thought I'd take a look at some of the Visual Studio 3.5 inbuilt validations but I soon discovered that they are very limited (oh unless you can download more of course): I added. So, I was hoping to get some advice as to what to do.
Here is a screenshot of the input page, I thought it'd be nice to put things in context:

Basically I need the date and hours fields to be validated against no input and invalid input and I have no idea what to do and what to use. THe date fields should be input in any this format 30/12/2014 or 30/12/2014 or 30.12.2014 or 30/12/14 etc (obviously any advice is accepted) and the hours should be in the range 0-168 (which I could do easily in visual studio with the range validation but then I realized that somehow it had to include the possibility that the field was empty, so I discarded the inbuilt …

Violet_82 89 Posting Whiz in Training

thanks

Violet_82 89 Posting Whiz in Training

that's partially what I did and what I'm doing. I looked for a book for a little while, found what looked good to me, as a real beginner, ASP.NET 3.5 A beginners Guide by William B. Sanders and I began to learn, by copying the exercises first and by doing small apps (I'm still working on the Overtime one by the way, https://www.daniweb.com/web-development/aspnet/threads/484634/overtime-application from scratch because I read a few things that convinced me that I was doing it the wrong way and it looks like I am getting it to work), so will see where we get :-). As for master pages, repeaters, grids etc, as I said before I knew nothing about those because they were not mentioned in the book - no book is perfect - but no doubt it will be good to look into that :-)

Violet_82 89 Posting Whiz in Training

you're right, it was, I closed the application and reopened it and it worked. master pages? Do you know any elementary tutorial specifically about master pages?
thanks

Violet_82 89 Posting Whiz in Training

Thanks JorgeM, I have used that approach because I didn't know any other I suppose. Never heard of a repeater control or grid view...sorry I'm still at the very beginning

Violet_82 89 Posting Whiz in Training

Hi guys, as I'm fairly new to visual studio and asp.net, I might be missing something really obvious here...basically I have created a CSS file which is referenced in the aspx file (I dragged the css file from the project to my aspx file). Then I created another aspx file and done the same thing and I have modified the css file, making some additions. After saving it and ctrlf5'ing I noticed that the css changes didn't go through. So, if I open the css file in visual studio I can see these changes but when I check in the browser they aren't there. Thinking I've made a mistake I went View Source in the browser and the changes are definitely not in the CSS, but I can see them when I open the file in visual...any idea?
thanks

75b0c444cc3066123cdae5255c9d1142 and referenced it on my aspx file, and it w

Violet_82 89 Posting Whiz in Training

Hello all,
I'm trying to change the innerHtml of a div in the code behind and noticed an interesting thing. If I have this situation:
aspx file:

<div id="displayPanel" runat="server">

</div>

C#

while(reader.Read()){
...
displayPanel.InnerHtml += "<span>"+ name + " has donated £ " + donation + "</span>";
}

everything goes as planned (the div is populated with how many rows are in the SQL table and the data is wrapped in a span as I wanted). But if the displayPanel div has a .net control in it as in

<div id="displayPanel" runat="server">
    <asp:Label ID="label1" runat="server" Text="label" />
</div>

with the same code behind, I get an error saying "Cannot get inner content of divID because the contents are not literal". Why is that? I'm not trying to get the innerHtml of the controller - which understandably could lead to a compiling error, but I'm trying to get the innerHtml of the div!
thanks

Violet_82 89 Posting Whiz in Training

OK thanks guys, so back to square one then. Sorry but this isn't yet clear in my head. Page Default.aspx has a reference to Default.aspx.cs where the code that uploads info onto the database resides. As JorgeM pointed out I know I could include the C# code in the aspx page but I prefer to have it in its own aspx.cs file for clarity. Then page Results.aspx will retrieve the info from the database, so if there is no much point in using classes due to the size of my project, is it OK to use another aspx.cs file, which Results.aspx referes to and which contains the code to retrieve stuff from the database? Is this approach better?
The reason why I asked whether it was possible to have one aspx.cs file for two aspx pages was because in my head I thought that it would have been more manageable and clearer

Violet_82 89 Posting Whiz in Training

Thanks pritaeas, well I'm not sure if they share code to be honest, but the idea of classes seems a good one. OK so, I have my two aspx pages Default.aspx and Results.aspx: the first uploads content to the database so I'll create a upload class file and since the second one retrieve it, I'll create a retrieve class file. Both the aspx files are linked to the same partial class (Defaut.aspx.cs, but how do I link 2 aspx files to the same aspx.cs file?) and in there on page load I can call the two separate classes, does it sound reasonable?

Violet_82 89 Posting Whiz in Training

Hello guys, I wonder if anybody could clarify this for me. I've created a new website (File > New > Web site) and as we all know I now have a aspx file (Default.aspx) and a aspx.cs file (Default.aspx.cs). The aspx file contains a form and when submitted, it sends some data to a small SQL table. What I would like to do is to create another page (web page, aspx file - I don't know, whatever) to display the data saved in the SQL table, so that I essentially end up with two pages: one which allows you to submit the info to the database and another one that displays that content. I have to say that my knowledge of asp.net, visual studio and SQL is very basic, so I tried to add a new item by clicking on the project (I seem to understand that a web form is another aspx file) but there is a problem: ideally, I will need to use the same aspx.cs file (with the addition of the relevant code to display the database content of course) to retrieve the information from the SQL table rather than write the C# code in a separate aspx.cs file. Is that possible? I kind of assumed it was and so in my second aspx file (Results.aspx) I included ...CodeFile="Default.aspx.cs" Inherits="Default"... so that it uses the same aspx.cs file, but the compiler didn't like it. So, my assumption might be wrong after all. Anyway, any suggestion as to …

Violet_82 89 Posting Whiz in Training

OK cool, thanks, I will have to use for both windows and linux though, so I probably need to partition it

Violet_82 89 Posting Whiz in Training

forgot to ask though, when I insert the second HD, the one where I will store all my documents etc, do I have to configure it somehow, or will it work out of the box?
thanks

Violet_82 89 Posting Whiz in Training

Actually, I had a good look and found a SQL SUM() method that seems to be doing what I need, well, at least on paper!
Now, I have changed my code-behind a little, and it is very clear to me that I still have a lot to learn in SQL and C#...

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page 
{
    private const decimal workingHours = 37.5M;
    private string toInsert;   

    private decimal dayOvertime;
  //  private string dayOvertimeString;
    //private decimal totalOvertime;
    private string Ovt;
    private SqlCommand sqlCmd;
    private SqlConnection hookUp;    

    protected void Button1_Click(object sender, EventArgs e)
    {
        hookUp = new SqlConnection("Server=localhost\\SqlExpress;Database=Overtime;" + "Integrated Security=True");

       toInsert = "INSERT INTO OvertimeTable(Week,WeekHrs,WeekOvt,Comment)VALUES(@Week,@WeekHrs,@WeekOvt,@Comment)";        
      sqlCmd = new SqlCommand(toInsert, hookUp);

        dayOvertime = Convert.ToDecimal(hours.Value) - workingHours;

        Ovt = "SELECT SUM(WeekOvt) AS TotalOvt FROM OvertimeTable";


        sqlCmd.Parameters.Add("@Week", date.Value);
        sqlCmd.Parameters.Add("@WeekHrs", hours.Value);
        sqlCmd.Parameters.Add("@WeekOvt", dayOvertime);        
        //sqlCmd.Parameters.Add("@TotalOvt", totalOvertime);
        sqlCmd.Parameters.Add("@Comment", "This is a comment");

       // sqlCmd = new SqlCommand(Ovt, hookUp);
        sqlCmd = new SqlCommand(toRead, hookUp);
        hookUp.Open();
        sqlCmd.ExecuteNonQuery();

        hookUp.Close();

    }
}

So, I have changed the data I push in the database:
toInsert = "INSERT INTO OvertimeTable(Week,WeekHrs,WeekOvt,Comment)VALUES(@Week,@WeekHrs,@WeekOvt,@Comment)";
In the above I am not inserting any value for the TotalOvt column, I am leaving it blank and the plan is to use it to store the total overtime (the column is still available in the database I haven't deleted it).
This is insted the line that, I believe, should get the …

Violet_82 89 Posting Whiz in Training

cool, thanks! I think I got a little stuck with the code behind, not sure if it's because of poor logic or what. Basically once I push the data in the database, somehow I have to increment the overall overtime and I don't seem to be able to find out how. Let's have a look at some code, maybe you guys have a better idea:
HTML

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Overtime.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
    <link href="styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <div class="wrapper">
        <h1>Overtime application</h1>
        <p>Insert week and hours worked</p>
        <div class="row">
            <label class="control-label" for="date">Enter date </label>
            <div class="controls">
                <input id="date" type="text" runat="server"/>
            </div>           
        </div>
        <div class="row">
            <label class="control-label" for="hours">Enter hours worked </label>
            <div class="controls">
                <input id="hours" type="text" runat="server"/>
            </div>
        </div>
        <div class="row">
            <asp:Button ID="Button1" runat="server" Text="Submit" onclick="Button1_Click" />
            <asp:Label ID="Label1" runat="server" Text="Label">dayOvertime</asp:Label><br />
            <asp:Label ID="Label2" runat="server" Text="Label">totalOvertime</asp:Label>
        </div>
    </div>
    </form>
</body>
</html>

C#

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page 
{
    private const decimal workingHours = 37.5M;
    private string toInsert;
    private decimal dayOvertime;
  //  private string dayOvertimeString;
    private decimal totalOvertime;
    private SqlCommand sqlCmd;
    private SqlConnection hookUp;
    /*protected void Page_Load(object sender, EventArgs e)
    {

    }*/

    protected void Button1_Click(object sender, EventArgs e)
    {
        hookUp = new SqlConnection("Server=localhost\\SqlExpress;Database=Overtime;" + "Integrated Security=True");
        toInsert = "INSERT INTO OvertimeTable(Week,WeekHrs,WeekOvt,TotalOvt,Comment)VALUES(@Week,@WeekHrs,@WeekOvt,@TotalOvt,@Comment)";
        sqlCmd …
Violet_82 89 Posting Whiz in Training

OK, I think I will add the row with jquery though, but I still need to find out how to add a js script to visual studio, lol! Anyway, I'm working out the server side of things, I thought I'd start from there and then when I sorted that out I will look into populating an html table with the right values. So far I get the c# code toget the values input by the user in the 2 input fields provided (date and hours worked) and pushed them into a SQL database. Now I am just writing the code - still c# - to calculate the daily overtime, add it to the overall overtime and push both onto the database. I should provide some code soon hopefully!

Violet_82 89 Posting Whiz in Training

Thanks, will this suffice as pseudocode?

-user to type date and total weekely hours worked in two separate input fields
- user click submit button
-jquery onclick function adds another row to the HTML table
-C# function calculates week overtime, add it to the total overtime, then push these values + the date and total weekly hours worked in a SQL database, and extract the values from the database populating the HTML table

So I kind of assume the addition of rows in the HTML table (not the SQL table) has to be taken care by jquery?

Violet_82 89 Posting Whiz in Training

Hello guys, a while back I posted something about what was needed to build an overtime app that stored data permanently on the server (here is the post https://www.daniweb.com/web-development/php/threads/467433/change-content-of-html-page-with-php) and I was told to use PHP. I have to say I've never got around that, but now I'm looking into asp.net and I was wondering whether this is possible to achieve using that and perhaps SQL (I don't know how well I have to know asp.net and SQL, I can only do small and simple applications as I 'm learning how to use.)
So, I already have the html code and the script that takes care of updating cells in a table and making the necessary calculations, but this is only at the front end:

<!DOCTYPE html>
<html>
    <head>
        <title>This is a test</title>
        <link rel="stylesheet" type="text/css" href="styles.css" >
        <script src="http://code.jquery.com/jquery.js"></script>
        <script type="text/javascript" src="script.js"></script>
    </head>
    <body>
        <table>
            <tr>
                <th>Week ending</th>
                <th>Total week hours worked</th>              
                <th>Week overtime available</th>
                <th>Total overtime</th>
                <th>Comments</th>             
            </tr>
            <tr class="editable">
                <td><input type="text" class="date"></td>
                <td> <input type="text" class="hoursWorked"></td>
                <td class="overtimeAvailable"> </td>              
                <td class="totalOvertime"></td>
                <td> <textarea type="text" class="comments"></textarea></td>                
            </tr>            
        </table>
        <button>Submit</button>
    </body>
</html>



$(document).ready(function(){
    var totalOvertime = 0;
    $("button").click(function(){
        var tableRow;
        var date;
        var hoursWorked;
        var overtimeAvailable;
        var comment;
        date = $("input.date").val();
        //console.log(date);
        hoursWorked = parseFloat($("input.hoursWorked").val());
        overtimeAvailable = hoursWorked - 37.5;
        totalOvertime += overtimeAvailable;
        comment = $(".comments").val();
        console.log(comment);
        console.log("hours " + typeof hoursWorked + " overtime " + typeof overtimeAvailable );
        tableRow = '<tr>' +
                        '<td class="date">' + date + '</td>' +
                        '<td class="hoursWorked">' + …
Violet_82 89 Posting Whiz in Training

OK thanks for all the suggestions :-)

Violet_82 89 Posting Whiz in Training

Ok thanks for that, yes I am using visual studio, still finding my way around things :-)

Violet_82 89 Posting Whiz in Training

um, yes it is confusing. OK, so you're effectively saying that whenever I use an asp controller or a HTML tag I should look them up on the MSDN ro check what property to use in C#? So, say the textBox http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.textbox_properties(v=vs.110).aspx, there is no "value" property listed, so I know I can't use that. Cool, this for a sp textBox. How about a input html tag though, MSDN won't have anything on that, but I still need to know - I appreciated you clarified this specific instance above so I am more talking in general terms now - whether I need to use a Text or a Value property for a HTML tag used in ASP.NET

Violet_82 89 Posting Whiz in Training

Cool, thanks. Now, I have to say I am not that knowledgeable when it comes to HD etc, so maybe you can tell me whether this is possible or not. Considering what we discussed above I will go with a big HD (let's call it disk B) and put it into the second slot available. On this HD I will install Ubuntu and then Windows 7 as a virtual OS. I would like to keep the old 250HD (let's call it disk A) where it currently is though, with all its content (and the 2 OS's) and I was wondering if I will be able to keep using it the way I do now if I want to: in other words will I be able to have 2 HD and still boot from disk A when I feel like, and use one of the two OS's in there, or boot from disk B and use one of the two OS's there, or is this complete heresy? There is of course a logic behind that, which is that I have so much software installed under Windows and Ubuntu on disk A that I can't possibly face a wipe out and reinstall - maybe I will in the long run but not straightaway.
thanks

Violet_82 89 Posting Whiz in Training

Hi guys, quick question. When I work with asp.net controllers (so say a TextBox or a Label) if I want to get what's inside them I will use the Text property: for asp.net listboxes instead I use the Value property. If I instead, say, I ditch completely the asp.net controllers and use equivalent HTML elements (input, textarea) I have to use the Value attribute when I use them within a asp.net environment (although for the HTML select tag I can still use the Text property). So, in view of the above, is there some kind of rule that tells me when to use what?

Violet_82 89 Posting Whiz in Training

Ah, OK thanks for clarifying that, so I suppose there isn't a rule as such as to when asp.net accept what.

Violet_82 89 Posting Whiz in Training

Thanks, I have to say I didn't consider all these things. My current HD is 250GB and as I said I have two OS's installed on it. Part of the problem with the upgrade is that ideally I want to keep my current settings (the 2 OS's on the same HD) and then in addition to have another virtual OS (windows 7) installed on ubuntu so I can run Windows 7 without rebooting. Now, if the settings you've described (having a ssd with the 2 OS's and the HDD with the media files) allows me to achieve the above, then I am more than happy to do that, but - and my understanding of virtualizazion are very poor - I thought that the OS to be virtualized had to be on the same HD of the OS from where the virtualization is done, in other words the virtual WIndows7 has to be on the same HD (or SSD) where Ubuntu is on: this I presume means that if I want to install software on the virtual OS, it has to go on the same disc or can it go onto the other HD with the media files etc?

Violet_82 89 Posting Whiz in Training

That's useful thanks, I had a quick look at it now. There is something strange though - OK perhaps because I am very new to asp.net - but tags like a textbox for the sake of argument is an auto close tag according to the MSDN library, and yet, I have seen instances of a textbox with a proper closing tag: is that a mistake? Visual didn't complain about it