DaveAmour 160 Mmmmmm beer Featured Poster

Those 2 urls are not the same!

DaveAmour 160 Mmmmmm beer Featured Poster

Top Tip - look at T4MVC

@Html.ActionLink("Delete Dinner", "Delete", "Dinners", new { id = Model.DinnerID }, null)

T4MVC lets you write

@Html.ActionLink("Delete Dinner", MVC.Dinners.Delete(Model.DinnerID))

https://github.com/T4MVC/T4MVC
https://visualstudiogallery.msdn.microsoft.com/8d820b76-9fc4-429f-a95f-e68ed7d3111a

DaveAmour 160 Mmmmmm beer Featured Poster

Have a look at T4MVC and @Url.Action

DaveAmour 160 Mmmmmm beer Featured Poster

Some more tinkerings - might also help.

Look at the DoSomething methods. In OO you shouldn't be asking if something is of a certain type and then acting accordingly, much better to use polymorphism as in the DoSomething Example.

void Main()
{
    var game = new Game();

    Player dave = new Player { Name = "Dave" };
    Player sarah = new Player { Name = "Sarah" };
    Computer mac = new Computer { Name = "Mac" };

    game.PlayerList.Add(dave);
    game.PlayerList.Add(sarah);
    game.PlayerList.Add(mac);

    foreach (var player in game.PlayerList)
    {
        Console.WriteLine(player.Name + " is a computer = " + (player.GetType() == typeof(Computer)));
    }

    Console.WriteLine();

    bool isCurrentPlayerComputer;

    game.CurrentPlayer = mac;   
    isCurrentPlayerComputer =  game.CurrentPlayer as Computer != null;  
    Console.WriteLine("Current Player {0} is a computer? {1}", game.CurrentPlayer.Name, isCurrentPlayerComputer);

    game.CurrentPlayer = dave;  
    isCurrentPlayerComputer =  game.CurrentPlayer as Computer != null;  
    Console.WriteLine("Current Player {0} is a computer? {1}", game.CurrentPlayer.Name, isCurrentPlayerComputer);

    Console.WriteLine();

    foreach (var player in game.PlayerList)
    {
        player.DoSomething();
    }   
}

public class Game
{
    public Game()
    {
        PlayerList = new List<Player>();
    }

    public List<Player> PlayerList { get; set; }

    public Player CurrentPlayer { get; set; }
}

public class Player
{
    public string Name { get; set; }

    public virtual void DoSomething()
    {
        Console.WriteLine("Doing something in the style of a player");
    }
}

public class Computer: Player
{
    public override void DoSomething()
    {
        Console.WriteLine("Doing something in the style of a computer");
    }
}
DaveAmour 160 Mmmmmm beer Featured Poster

I'm not really sure what you are after but I did some tinkering - might help, might not.

void Main()
{
    var game = new Game();

    Player dave = new Player { Name = "Dave" };
    Player sarah = new Player { Name = "Sarah" };
    Computer mac = new Computer { Name = "Mac" };

    game.PlayerList.Add(dave);
    game.PlayerList.Add(sarah);
    game.PlayerList.Add(mac);

    foreach (var player in game.PlayerList)
    {
        Console.WriteLine(player.Name + " is a computer = " + (player.GetType() == typeof(Computer)));
    }
}

public class Game
{
    public Game()
    {
        PlayerList = new List<Player>();
    }

    public List<Player> PlayerList { get; set; }

    public Player CurrentPlayer { get; set; }
}

public class Player
{
    public string Name { get; set; }
}

public class Computer: Player
{

}
DaveAmour 160 Mmmmmm beer Featured Poster
public class MyModel
{
    public Model1 Model1 { get; set;}
    public Model2 Model2 { get; set;}
}
DaveAmour 160 Mmmmmm beer Featured Poster

Use an absolute network path?

DaveAmour 160 Mmmmmm beer Featured Poster

I think bulk uploads look for files on the machine SQL is running on.

DaveAmour 160 Mmmmmm beer Featured Poster

Does it exist on the database server?

DaveAmour 160 Mmmmmm beer Featured Poster

It is shared because you used "static"

DaveAmour 160 Mmmmmm beer Featured Poster

Not sure if this is right but try emoving brackets:

document.getElementById('clickMe').onclick = testOne;

DaveAmour 160 Mmmmmm beer Featured Poster

In this case Contact is class. It represents a contact in my domain.

It would be a User, Person, Company, Book, Item etc

I have made the assumption you are using Entity Framework - is this in fact the case?

    public class Contact
    {
        public int Id { get; set;

        public string Firstname { get; set; }

        public string Surname { get; set; }

        public string Company { get; set; }

        public string Telephone { get; set; }

        public string Mobile { get; set; }
    }
DaveAmour 160 Mmmmmm beer Featured Poster
  1. Get the current item from the database

  2. Update just the properties you want to change

  3. Use the Repository Pattern to execute code simillar to that below

        public void Update(Contact contact)
        {
            using (var context = new EfContext())
            {
                Contact existingContact = context.Contacts.Single(c => c.Id == contact.Id);
    
                context.Entry(existingContact).CurrentValues.SetValues(contact);
    
                context.SaveChanges();
            }
        }
    
DaveAmour 160 Mmmmmm beer Featured Poster

What actually happens?

DaveAmour 160 Mmmmmm beer Featured Poster

There are various ways. BackgroundWorker is probably best.

DaveAmour 160 Mmmmmm beer Featured Poster

What is the code doing? If it is on the main thread and it is doing a lot it can freeze the UI. Consider running the code on another thread.

DaveAmour 160 Mmmmmm beer Featured Poster

I have that too.

DaveAmour 160 Mmmmmm beer Featured Poster

You can set this in your web.config eg:

  <system.web>
    <customErrors mode="Off" ></customErrors>
    <compilation debug="true" targetFramework="4.5" ></compilation>
    <httpRuntime targetFramework="4.5" ></httpRuntime>
    <authentication mode="Forms">
      <forms loginUrl="~/Account/Login" timeout="2880" ></forms>
    </authentication>
    <pages>
      <namespaces>
        <add namespace="System.Web.Helpers" ></add>
        <add namespace="System.Web.Mvc" ></add>
        <add namespace="System.Web.Mvc.Ajax" ></add>
        <add namespace="System.Web.Mvc.Html" ></add>
        <add namespace="System.Web.Optimization" ></add>
        <add namespace="System.Web.Routing" ></add>
        <add namespace="System.Web.WebPages" ></add>
      </namespaces>
    </pages>
  </system.web>
DaveAmour 160 Mmmmmm beer Featured Poster

Should $ITEM be inside the speech marks?

DaveAmour 160 Mmmmmm beer Featured Poster

Also it also seems FF doesn't like "scroll" - try renaming your function to something else.

DaveAmour 160 Mmmmmm beer Featured Poster

Actually it might be that you closed your a tag twice.

Remove the / at the end of the first part of the a tag.

DaveAmour 160 Mmmmmm beer Featured Poster

Works for me: https://jsfiddle.net/xyt0527j/

FF Version 33.1.1

DaveAmour 160 Mmmmmm beer Featured Poster

Here's my go:

    <script>
        function CustomDate()
        {
            this.date = new Date();  
            this.dayPart = this.date.getHours() < 12 ? "AM" : "PM";

            this.toString = function()
            {
                return this.date.getMonth() + "/" + this.date.getDate() + "/" + this.date.getFullYear()
                    + " - " + this.date.getHours( ) + ":" + this.date.getMinutes()
                    + ":" + this.date.getSeconds() + " " + this.dayPart;
            };
        }

        var d = new CustomDate();

        alert(d);
    </script>
DaveAmour 160 Mmmmmm beer Featured Poster

Can you be a little more specific.

For example have you already

a) Created a MVC project?
b) Created a Controller?
c) Created a Controller Action?
d) Created a View

And so on...

DaveAmour 160 Mmmmmm beer Featured Poster

What do you mean by manually?

DaveAmour 160 Mmmmmm beer Featured Poster

If you are iterating over a collection which has enumerable properties then you can use foreach. For example:

foreach (var customer in customers)
{
    Console.WriteLine(customer.FirstName + " " + customer.LastName);
}

You could also achieve the same with a for loop:

for (var i = 0; i < customers.Count; i ++)
{
    Console.WriteLine(customers[i].FirstName + " " + customers[i].LastName);
}

In this case the first is more readable and easier to code right?

If you want to do a loop for some other reason though such as not iterating over a collectio but doing something x times then maybe a for loop is better. Also a for loop gives you access to the number of iterations you are on. So if you want to output:

1 Dave Amour
2 Fred Bloggs
3 Sarah Smith

Then there may be a case for using a for loop - it's up to you to make that call though.

Note - in order to be able to use foreach then the collection you are iterating over must implement IEnumberable or IEumerable<T>. Almost all collections do.

Here is a console app you can tinker with.

using System;
using System.Collections.Generic;

namespace ForeachVerusForLoop
{
    class Program
    {
        static void Main(string[] args)
        {
            var customers = GetCustomers();

            foreach (var customer in customers)
            {
                Console.WriteLine(customer.FirstName + " " + customer.LastName);
            }

            for (var i = 0; i < customers.Count; i ++)
            {
                Console.WriteLine(customers[i].FirstName + " " + customers[i].LastName);
            }

            Console.ReadKey();
        }

        static List<Customer> …
DaveAmour 160 Mmmmmm beer Featured Poster

Delete Line 30, 31 and 33

Move Line 32 to after your loop

Change "else if ( Number <0)" to "else" - no need to check as it must be less than 0

DaveAmour 160 Mmmmmm beer Featured Poster
DaveAmour 160 Mmmmmm beer Featured Poster

What does it return then?

Is it working or Erroring?

DaveAmour 160 Mmmmmm beer Featured Poster

In what way is it not working?

DaveAmour 160 Mmmmmm beer Featured Poster

That already is ajax. Can you be more specific?

DaveAmour 160 Mmmmmm beer Featured Poster

You can call a function from anywhere.

You can call a function from main and this function inside it's body can call other functions. Those other functions can also call functions. This is how you build up complex applications.

A recursive function is one that calls itself. This is often used for things like traversing a directory structure or things of that nature.

There are many good tutorials on this.

Check out the following for example.

http://www.zentut.com/c-tutorial/c-recursive-function/
http://www.programiz.com/c-programming/c-recursion
http://www.cprogramming.com/tutorial/lesson16.html

Hope that helps.

DaveAmour 160 Mmmmmm beer Featured Poster

Ok cool, this is what I said right from the start!

DaveAmour 160 Mmmmmm beer Featured Poster

Show me the design of the table in the GUI please.

DaveAmour 160 Mmmmmm beer Featured Poster

Here is one way.

using System;
using System.Linq;

namespace ForEach
{
    class Program
    {
        static void Main(string[] args)
        {
            const string s = "111\n222\n333";

            foreach (var line in s.Split('\n').ToArray())
            {
                if (line == "333")
                {
                    Console.WriteLine("Found the 333 number");
                }
            }

            Console.ReadKey();

        }
    }
}
DaveAmour 160 Mmmmmm beer Featured Poster

This should be really easy and to repeat my first reply to this thread, just debug the code and see what is happening.

Have you done this or not? It should be the very first thing you should ever do when something like this doesn't work.

DaveAmour 160 Mmmmmm beer Featured Poster

Sorry I thought you said it was working now? Is it working or not?

DaveAmour 160 Mmmmmm beer Featured Poster

Did you change the data being insrted/updated?

DaveAmour 160 Mmmmmm beer Featured Poster

This error message means you are trying to insert or update data which is too long.

Eg trying to enter "Dave" into a database column defined as only being 3 characters in length.

Decrease your data or increase your column width.

DaveAmour 160 Mmmmmm beer Featured Poster

It just means you are declaring a variable called flag and giving it a value of 1 or 0. This will presumably be used elsewhere in the code to keep a track of the state of something. It is also probably boolean in nature.

DaveAmour 160 Mmmmmm beer Featured Poster

Read a book, watch some videos, take a class, find a provate tutor, read a website.

The above advice also applies to T in HowToLearn<T>

DaveAmour 160 Mmmmmm beer Featured Poster

Hi Thomas

I don't code in C++ but in C# we would do this with a static property.

I do think you may be misunderstanding inheritance.

Could you post the simplest version possible of code needed to demonstrate what you are trying to achieve and I can comment further.

DaveAmour 160 Mmmmmm beer Featured Poster

Its badly formed, should be />

:)

DaveAmour 160 Mmmmmm beer Featured Poster

Can't you just debug it and see. Do you know how to debug and step through code?

DaveAmour 160 Mmmmmm beer Featured Poster

Ok you will need image recognition software then in case someone tries to inject some brie or red leicester by mistake.

DaveAmour 160 Mmmmmm beer Featured Poster

What is Foto - is that some kind of goats cheese?

DaveAmour 160 Mmmmmm beer Featured Poster

Ok I am going to attempt to solve this even without seeing your code even though that goes against my scientific nature.

Do you by any chance have JavaScript thinking your variables are strings and not numbers?

Did you do something like this maybe?

http://www.paxium.co.uk/content/daniweb/ifstatement.html

<body>
    <script>
        $(document).ready(function()
        {
            var maxGrootte = $("#t1").val();
            var minGrootte = $("#t2").val();

            if(maxGrootte < minGrootte)
            {
                alert(maxGrootte + " is less than " + minGrootte);
            }
            else
            {
                alert(maxGrootte + " is not less than " + minGrootte);
            }            
        });
    </script>

    <input type="text" id="t1" value="12" />
    <input type="text" id="t2" value="5" />
</body>
DaveAmour 160 Mmmmmm beer Featured Poster

Show me your code though please - there is something wrong with it but I can't fix it unless you show it to me.

DaveAmour 160 Mmmmmm beer Featured Poster

It is far more likeley that you have done something wrong.

For example you have two spellings of minGrooote there. One with one t and one with two ts.

Can you show me the code where you declare and assign values to these two variables?

DaveAmour 160 Mmmmmm beer Featured Poster

Can you try with a different browser?

Also can you see any of these sites?

http://www.rugeleychessclub.co.uk/
http://www.katmaid.co.uk/