« first day (53 days earlier)      last day (4899 days later) » 

9:24 AM
wow.... has anyone used linq to sql for their ASP.NET websites?
I just realised how disgustingly slow it is
... is it just me? how can it take 6 seconds to perform the same action as equivalent SQL does in 14 milliseconds?
 
You must be doing something wrong then, is my guess
 
I must be... but we're only using simple selects, maybe one or two joins... building simple data types
 
Can you show me one of those LINQ queries?
 
var dbMenus =
from menu in db.Menus
join menuType in db.MenuTypes
on menu.FkMenuTypeId equals menuType.Id
select new Menu
{
Id = menu.Id,
Type = new MenuType
{
Id = menuType.Id,
Name = menuType.Name
}
};
 
Any one there?
 
9:35 AM
no
 
how is .Menus and .MenuTypes declared?
 
@Greg Hello
I have problem with asp.net _dopostback JS. The error console says "__dopostback is not defined"
 
@LasseVKarlsen its from the dbml ... visual studio created that for me.
@SriKumar what browser / OS?
 
@Greg Ok, guess next step is to profile SQL Server then to see what kind of SQL is generated for your queries
Common mistake, not that I say you've made it, is to get a queryable converted to an enumerable, and then iterating over it, in effect doing full table scans with in-memory in-client filtering
 
@LasseVKarlsen a whole load of crap is generated. So many lines of SQL - already profiled the SQL server
 
9:44 AM
@Greg Win Xp/FF
 
@SriKumar the most common reason is that ASP.net simply hasn't created the javascript - usually because the viewstate of the page hasn't been enabled
 
@Greg added EnableViewState="true" to the aspx Page declarative
 
@SriKumar well if that doesn't work, check to see if the __dopostback javascript function is actually there in the source
open up the source and ctrl+f
 
@Greg Yes I can find the _dopostback in my browser page source
 
@SriKumar is there anywhere in the source where you have forgot to close the <script> tag ... or tried using /> notation?
 
9:49 AM
<body>
 <form id="frmLogin" runat="server">
  <asp:Button ID="btnClick" OnClientClick="openConfirmDialog();" OnClick="PopulateLabel"  runat="server"/>
  <div id="divDialog"></div>
  <asp:Label ID="lblText" runat="server"></asp:Label>
 </form>
</body>
<script type="text/javascript">
 $(document).ready(function() {
 $("#divDialog").dialog({autoOpen: false,
                     buttons: { "Ok": function()
                                      {
                                         $(this).dialog("close");
                                      },
                                "Cancel": function()
                                      {
                                          $(this).dialog("close");
                                      }
protected void Page_Load(object sender, EventArgs e)
 {
    lblText.Text = "";
 }

protected void PopulateLabel(object sender, EventArgs e)
 {
    lblText.Text = "Hello";
 }
 
I see no </script>
 
<script type="text/javascript">
  $(document).ready(function() {
    $("#divDialog").dialog({autoOpen: false,
                         buttons: { "Ok": function()
                                          {
                                              __doPostBack("btnClick", "");
                                             $(this).dialog("close");
                                             alert(1);

                                          },
                                    "Cancel": function()
Sorry this is my complete aspx page
 
hmmm, to be honest I've never directly called the __doPostBack function from within JavaScript
you could submit the form or something using JavaScript, but not sure what the outcome is if you call the function yourself.
 
@Greg Ok What would be the best way to achieve it herere
I mean I need to open a dialog box and only when user click OK I need to call the C# function
 
@SriKumar if you want to submit a form using JavaScript you can do document.formName.submit() or using jQuery $("#formId").submit();
@SriKumar to make a "OK / Cancel" dialogue box, you can use JavaScript's confirm("Question?");
 
9:55 AM
@Greg But will that actually call the user defined function in C#?
 
Confirm() returns true when the user presses OK, false when the user pressed Cancel
 
@Greg Sorry it would yes/No type and I cannot user confirm here :(
 
@SriKumar make the Confirm() post back the form if it returns true.
@SriKumar oh yeah I see, in your dialog's OK function, just submit the form there.
 
@Greg Ok but how the system know what eventhandler/function should be called on submit? Wont it just called ONLY Pageload ?
 
@SriKumar set a value in the form, and because it is runat=server, you will be able to see the value in c#
 
10:00 AM
@Greg Yes $("#formId").submit() post the value to server but it calls only the PageLoad, but here I want to call a specific function that will actually handle the "OK" functionality
 
@SriKumar so set a value in the form using JavaScript, and in Page_Load, check the value ... if it is your value then call a function.
 
@Greg I thought about it but it will be workaround :)
@Greg Yet another work around would to have hidden button and trigger its click event in JS which would actually call the respective eventhandler
 
 
1 hour later…
11:25 AM
Hello anyone in?
 
very quick question
@LasseVKarlsen if I had the following code:
var r = s.Split(';')[1];
how can I check that the index is empty? because it may or may not be empty.
 
what can be empty? s?
 
eg s may be bla;foo;bar
 
then r will be "foo"
 
11:34 AM
yes in that case, but if I said
var r = s.Split(';')[3];
 
Then you'll get an exception
 
yes, how can I check for this (thus avoiding an exception)
 
var parts = s.Split(';');
if (parts.Length > n)
    var r = parts[n];
 
well, that's ok for that case, however for the general case:
var r = s.Split(';')[n];
 
just substitute n for 3
 
11:36 AM
I was thinking about using the "??" operator somehow
 
You can use the ? operator
 
how would that look?
 
var r = (s.Split(';').Length > n) ? s.Split(';')[n] : "";
however you will do the split twice
 
I could optimize it by first splitting it and storing the "length" in a variable and use that instead
 
var parts = s.Split(';');
var r = (parts.Length > n) ? parts[n] : "";
 
11:40 AM
Thank you that's exactly what I was looking for!
@LasseVKarlsen
those two lines has just replaced a big ugly switch statement!
 
 
2 hours later…
1:28 PM
ASP.NET: If I have objects in my DataSource i.e .Select(e => new { Foo = new { Bar = "HelloWorld" } } , how do I referece this using Eval? Eval("Foo.Bar") doesn't work?
 
@NielsBosma I'm pretty sure you can use anonymous types like that
 
1:51 PM
ok, I was afraid of that
Have posted on SO as well
Would be quite useful if it was possible
2
Q: ASP.NET: Objects in Eval

Niels BosmaIf I have objects in my DataSource i.e .Select(e => new { Foo = new { Bar = "HelloWorld" }, Price = 12345 } how do I reference this using Eval? <%# Eval("Foo.Bar") %> doesn't work? (Eval("Price") does....) Is there anyway to do <%# Eval(Eval("Foo"),"Bar") %> or something ?

 
2:11 PM
Guys anyone wants to help me debug a WPF binding that isnt working? i basically copy-paste'd the code from another working binding but it simply doesnt work :S
 
I'll help if I can, those can be notoroiusly difficult to debug
 
Yeah
The Observablecollection isnt null, yet there is no data displayed on the Datagrid
 
using VS 2010?
 
/facepalm
I had to load the items in the collection BEFORE the InitializeComponenet
InitializeComponent();*
It works now
 
duh :P
 
2:15 PM
Sorry :p
 
Np, glad I could help!
 
Now i have to disable the auto-column-generation before i can move on
Thanks tho you are really helpful guy :)
 
Np, I must admin tho, I didn't really do anything that time ;)
 
BTW: Are you experienced with the WPF DataGrid?
I want to remove that little border to the left of the grid :@
 
Not really, I usually end up using the 3rd party grids like Telerik's
 
2:22 PM
:/
Ill check up Telerik's controls now that i think i have enough .NET Wisdom to use them :p
 
they're very nice, not cheap tho
 
Ill download demos if they are available
May buy
 
Isn't there an attribute that you can apply to enum values that sets its "textual representation"
 
Hmmm... Enums just wrap around int values as far as i know
So i dont really understand your question
 
I thought I had saw that somewhere, but I think it was something someone had written
not a part of bcl
 
2:28 PM
Ok, now that i got my transformer textblock style and my datagrids going its time to wire everything up
 
:)
Damn! Finally found that track i had been searching for ages
Lovely massive trance
Want to listen to it?
 
no thanks, I'm good :)
 
Ok
 
I'm at work, so music and stuff like that carries down the halls ;)
 
2:31 PM
Oh
I love how WPF just saves you thousands of code lines yet requires you to think about stuff a lot
A framework for lazy-typers not lazy-thinkers
 
yea, I love WPF in general
 
:)
 
so, can someone fill me in on the difference between ADO.NET Entity + LINQ and LINQ to SQL?
all I can figure is ADO.NET supports multiple DBMS's and it has some sort of schema translation
 
ADO.NET is the underlying technology that both EF and L2S use, it's the "raw" database connection layer
 
yes, I've used it in the past, but what about EF?
 
2:44 PM
EF and L2S are different ORM technologies that provide similar functionality, EF is much more flexible that L2S is tho
 
is there any downside to EF?
 
"With great power comes great responsibility" ;)
It's much more flexible, so there's a bit more complexity
 
@CodingGorilla A stupid programmer can and will write bugs in the simplest framework
 
L2S is pretty simple and straight-forward, it's something that I would use for a project that just has really dead simple database work
So can the best programmer ;)
 
agreed
EF allows you to name your object differently than your tables, right?
 
2:47 PM
I think both of them do
 
it was very tricky in L2S, if I recall
easy to overwrite up if you needed to change/rebuild the schema
 
The big thing that EF offers is custom code generation, where L2S builds the code for you and there's not a lot you can do to change it
 
ok
 
In EF you can write your own T4 templates and completely replace the code generation (as of v4 that is)
 
that's pretty freaking awesome
 
2:48 PM
Yep, but it also has some gotchas that you have to be aware of
 
3:03 PM
@CodingGorilla is there a list of those somewhere?
 
Only in the MSDN documentation AFAIK
 
3:23 PM
Guys anyone here knows how can to Datagrid's selected row?
 
Can you rephrase the question using English? =P
 
Lol
I somehow skipped bind
 
So you want to bind to the DataGrid's selected row?
 
How can i bind to a Datagrid's selected row
but to a specific field of the selected row
 
What I would do is to have the row selection [event] update a property on my window, model, whatever, and then bind to that property
 
3:26 PM
Hmmm
 
I think there's a tendancy in WPF to want to go on this binding spree where you build this hugely complex inter-bound window, but usually you can make things a lot simpler by doing things like what I said above
 
But what about a case where the user selects no rows?
Oh, i just want to keep the code-behind file as clean as possible
 
Even better, because your property can interpret NULL as "Not Selected" for you
 
Try to stick to this new MVVM thing i dont know much about :p
Hmm, will try that
Thanks
 
In that case, then what I suggested is what you should be doing
The selection in the grid should be reflected in your model (or you wouldn't be able to test it), and then your UI should be updated from that model (i.e. your other control)
 
3:30 PM
Will do, thanks
 
4:11 PM
I was thinking about developing a 2D game in C# on my Windows mobile, have anyone had some experience in this? Is XNA the way to go, or is there some other way to do it? Basically the game is just images moving around. I've tried Windows Forms but it's kinda slow. :P
 
Windows Phone 7, or older versions?
 
older, 6.3
 
I dont think the older mobile OS's support XNA, but I honestly dont have any experience.. sorry =\
 
Hm, okay
Perhaps I can learn C++, hehe
 
Good luck with that ;)
 
4:15 PM
:)
The phone supports the "old win32", as in no gdi+
 
yea, they really weren't designed for gaming, I dont think you're really going to get good performance out of it no matter what you do
 
I guess the (old) phones were not meant for games
 
but like I said, I don't have any experience so I could be totally wrong
 
I'm gonna take your experience for it, but I'm gonna look around. Thanks
 
 
5 hours later…
8:56 PM
@Patrick GDI+ is pretty slow, you might be better off with GDI for games
 

« first day (53 days earlier)      last day (4899 days later) »