« first day (2303 days earlier)      last day (2871 days later) » 

00:40
Hello!
WPF room seems empty so I will ask here,
In blend 2015 they removed option to make into control and select what type will it be
WHY?
now I can only make it into UserControl but I need button behavior for my custom button
01:22
@KevinMaxwell something that look like
async Task<ActionResult> Login(LoginViewModel model)
public ActionResult Test(Guid? cid, Guid? mid)
        {

            ViewBag.cid = cid;
            ViewBag.mid = mid;

            var generalneeds = db.GeneralNeedTypeDD.Where(x => x.Deleted == false).Select(x => new SelectListItem()
            {
                Text = x.Definition,
                Value = x.Code,
                }).OrderBy(x => x.Text);

           var model = new PAGeneralNeedsViewModel()
            {
                Needs = generalneeds
            };

            return View(model);
Post
public ActionResult Test(PAGeneralNeedsViewModel test, Guid? cid, Guid? mid, string[] selectedGeneralNeed, string[] unique)
        {
            ViewBag.cid = cid;
            ViewBag.mid = mid;

            if (ModelState.IsValid)
            {

                selectedGeneralNeed = selectedGeneralNeed ?? new string[] { };
                unique = unique ?? new string[] { };
                foreach (var item in selectedGeneralNeed)
                {
                    var code = db.GeneralNeedTypeDD.Single(s => s.Code == item);
I tried that code, what it happens is this:
I checked two items and I wrote text for each. But EF saved multiple times of each per Comment
For Type 1 Comment should be 3
For Type 3 Comment should be 32
I did that via Name attribute. This name attributes works perfectly if I only care about Checkboxes, but in this situation I should also have co-related Comment to checkbox
@juanvan Thanks for coming back :)
@foreach (var item in Model.Needs)
{
    <li class="panel panel-default">
        <div class="panel-heading">

            @Html.Label(item.Text, new { @class = "f-12 w-300 control-label text-semibold", @for = item.Value })
            <a class="secondary-content">
                <div class="togglebutton togglebutton-material-green">
                    <label>
                        <input type="checkbox" name="selectedGeneralNeed" value="@item.Value" checked="@item.Selected" class="md-checkbox" [email protected] />
Where is the @Html.BeginForm
01:37
I didn't copy it.
@using (Html.BeginForm("Test", "Wizard", new { cid = ViewBag.cid, mid = ViewBag.mid }, FormMethod.Post, new { id = "dynamicform" }))
VM: public virtual IEnumerable<SelectListItem> Needs { get; set; }
why does the type come in 2 times under different levels?
you mean inside the table?
That's the exact issue. It should be one. 1 and 3
not 1 1 and 3 3
so the problem is you picked 2 item but 4 came over
01:43
yes, I checked two Checkboxes with their comments
it gave me 4 rows
I'm just surprised that I can't find any similar issue on SO.
@juanvan Thanks for helping. I'll try more to find a solution.
01:59
that is really strange
I have never seen that from my testing
I would try 1 then work your way up
Have you ever done this?
I think I know why, because I'm using multiple Foreach before Saving. But I don't know how else can I get the Text value for each...
Oh ya
based on my selection it will make it x how many selected
3*2 = 6 and etc.
why do you have more then 1 for each
It's because of the following part:

To get the checkbox values I use name attribute: string[] selectedGeneralNeed
selectedGeneralNeed = selectedGeneralNeed ?? new string[] { };

Then I loop this which is correct
I have another name attribute for the Comment field
string[] unique
I can't use the array of items without loop, can I?
I can't use:
Comment = unique
02:04
you should be getting a list<t> back in the view model
I actually tried For loop instead of Foreach and I also prepared my VM to have the following objects:

public int Id { get; set; }
public string Value { get; set; }
public string Text { get; set; }
public bool Checked { get; set; }
public string Comment { get; set; }
After this I got another problem, I couldn't bind my lookup tables(which is the items displayed on the screen) as list.
Inside VM:
public List<PAGeneralNeedsViewModel> Items { get; set; }
I used this in Get method:

var generalneeds = new List<PAGeneralNeedsViewModel>(db.GeneralNeedTypeDD.Where(x => x.Deleted == false).Select(x => new PAGeneralNeedsViewModel()
            {
                Text = x.Definition,
                Value = x.Code,
                Id = x.Id
            }).OrderBy(x => x.Text));

var model = new PAGeneralNeedsViewModel()
            {
                Items = generalneeds
            };
I updated my View
@for (var i = 0; i < Model.Items.Count; i++)
{
    @Html.HiddenFor(m => m.Items[i].Id)
    @Html.HiddenFor(m => m.Items[i].Text)
    <li class="panel panel-default">
        <div class="panel-heading">

            @Html.Label(@Model.Items[i].Text, new { @class = "f-12 w-300 control-label text-semibold", @for = @Model.Items[i].Id })
            <a class="secondary-content">
                <div class="togglebutton togglebutton-material-green">
                    <label>
                        <input type="checkbox" name="selectedGeneralNeed" value="@Model.Items[i].Value" checked="@Model.I
One problem at a time
;-)
I'm testing now...
No luck!
what you should be getting back in that Post back is a ViewModel that has a list of<t> where T is the TextBoxes and CheckBoxes
02:19
exactly, but it seems I'm not able to do it or don't know it at all.
you should be using the @Html.Helpers
that will help bind the model to the page
Ok, but then how I get those values during the Save?
Foreach or For?
yep for each collection
and the same for View?
Because, For loop generated unique id for each control.
you could try to pull it like that with the unique ID but that is harder then letting the model bind back
02:28
I would like to use the binding instead of Name. My last question, so I should use Foreach loop on both View and Controller, right?
System.NullReferenceException: Object reference not set to an instance of an object
On saving...
Even this doesn't help:

foreach (var item in test.Items)
                {
                    var code = db.GeneralNeedTypeDD.Single(s => s.Code == item.Value);
                    var generalneed = new GeneralNeeds()
                    {
                        CaseId = cid,
                        MemberId = mid,
                        Type = code,
                        Comment = item.Comment,
                        Level = db.LevelTypeDD.SingleOrDefault(x => x.Code == "M"),
                        Status = db.GeneralNeedStatusDD.SingleOrDefault(x => x.Code == "REC"),
@foreach (var item in Model.Items)
{
    <li class="panel panel-default">
        <div class="panel-heading">

            @Html.Label(item.Text, new { @class = "f-12 w-300 control-label text-semibold", @for = item.Value })
            <a class="secondary-content">
                @Html.CheckBoxFor(x => item.Checked)
            </a>

        </div>
        <div class="panel-body">
            @Html.TextBoxFor(x => item.Comment)
        </div>
    </li>
}
For example: item.checked in View has no value. Checkboxfor only takes Bool
Is this correct?
public List<PAGeneralNeedsViewModel> Items { get; set; }
Woohoo!! @KevinMaxwell
03:26
Dang... I been adding feature and random updates to my Self-Project for over 2.5 year it started with me just Starting WPF so early codes are lame and WebForm-like.

Now I'm trying to rewrite it all in a good elegant standard way :D but it's just so much !! working on it for a whole day only on XAML Design... and its not even 15% Done yet xD let alone C# codes :| I'm surprised how I write these all the first time lol
03:36
I ran into an optimization freak. Help!
 
7 hours later…
10:19
Bonjour
oh hey, nice
just learned about the [Bind] attribute in MVC
Saw an example and was like ew, magic strings...surely that can be made better
Yep! nameof() is compile-time constant, so you can do [Bind(Include = nameof(Myclass.MyProperty))]
 
2 hours later…
11:52
posted on February 04, 2017 by Scott Hanselman

I'm in Nairobi, Kenya this week attending a fantastic event called NexTech Africa. It is a free event that showcases the best of what Africa's Startup community has to offer. This event is mostly focused on East Africa's tech community but it included delegates from all over the continent. I'm told over 1000 people are here. My wife is Zimbabwean and we have family all over in places like So

 
3 hours later…
14:51
@TomW That's cool.
 
1 hour later…
16:04
why sometimes recently after i install something from NuGet ... it add to reference but got a yellow error near it saying it's not found O.o ? then i have to reinstall and it fix :|
 
3 hours later…
19:04
Hi,
I am working on importing a text file into database in mvc. I'm pretty new to mvc. Can anyone guide me achieve this?
19:30
Importing text file in database is 90% C# 10% mvc and thats making a button to do it xD uploading a text file or getting input from user to database that's a little more MVC
19:41
@Pedram can I have any useful link ???
@Orion you'll need to be a lot more specific in order to give you useful advice
For a start, files don't generally go in databases
@TomW: You play games right? Do you have overwatch?
I do occasionally but no I do not
It doesn't really appeal to me
Too console-y
19:48
I like the arcade / fast gameplay. Reminds me of quake 3.
What do you usually play? fps, rts, rpg?
used to play a decent amount of Battlefield 3/4
Slowly plugging my way through Fallout 4
the new XCOMs
Fallout looks nice, and so do the latest XCOM games too. Just haven't gotten around to trying them out.
XCOM is really tense
Fallout is getting easy
It's hard when you're a complete newb and all your stuff is poop
yeah, I guess it gets easier after putting some hours into it.
If you dither about doing the side quests etc you tend to hang around in the easier part of the world rather than pushing out into the dangerous areas
19:56
No pain, no gain.
:)
i.e. the quests will tend to have destinations near-ish you, although not always. If you do them all you're accumulating XP faster than you need to keep parity with the environment, is what I mean
I can oneshot most of the regular grunty type enemies that appear in my area now
so the game is getting boring
So you're OP compared to the current zone?
yeah
Can't you just move into some harder zones, which requires higher level?
and get bigger rewards from the quests?
I could but other than following the main storyline and ignoring the side quests, I'd just be wandering around killing monsters for no reason
19:58
Just thinking about how it is in mmo's.
The main storyline will tend to push you into going into areas that challenge you, the side quests less so, I find. They could have balanced it better to be more challenging, is all I'm saying
XCOM on the other hand is really fing hard, or feels that way. Different genre obviously
particularly in XCOM 2 the development of the storyline seriously punishes dawdling, it'll fuck you up really hard if you don't rush
like every 3-4 missions it'll threaten you with "complete one of these three side missions to not get nerfed"
hehe
that kind of sucks a bit, but I guess it's part of the general progression?
They're usually hard, and either you lose most or all of your team or you fail and you get nerfed - and then it'll often either nerf you again in your next mission or bring out a new super tough unit you've never seen before
yeah XCOM has always been known for being really hard, at least perceived to be
they know what players value, and regularly punish you for it
It's a game of choosing which punishment you hope will hurt you the least
Think I'll give the new xcom a try. Sounds pretty interesting
There's a load of customisation of your soldiers to make you fond of them
then if one gets really good, there will often be a really tough hitman unit in your next mission
20:40
if i create a button in .xaml.cs, how do i set it a mouse button event args method?
button.Click += Button_Click_Event;
...
private void Button_Click_Event(object sender,RoutedEventArgs e)
{
    // Do your stuff...
}

« first day (2303 days earlier)      last day (2871 days later) »