Archive for September 23rd, 2007

What is wrong with this code?

ASPX file:


<p>
    The time is now <asp:Literal runat="Server"adz">
There is, however, a better way: Declarative DataBinding. ASPX:

<p runat="Server">
The time is now <%# CurrentDateTime.ToString() %>.
<br />
And the current longdate is <%# CurrentDateTime.ToLongDateString() %>.
</p>

Codebehind:


protected override void OnLoad(EventArgs e)
{
    DataBindingContainer.DataBind();
}

protected DateTime CurrentDateTime
{
    get { return DateTime.Now; }
}

There are a few things to note about the codebehind here. First is the call to DataBindingContainer.DataBind(). This is because you must make a call to DataBind() the container with any declaratively bound elements. Second is to note how we made a protected property for the CurrentDateTime. We could have bound to directly DateTime.Now, but I chose to show this as a protected property for a reason: DataBinding actually occurs in a system-generated class that inherits from your page, so anything called from the ascx template must be accessible to that class; private variables need not apply.

You might wonder why I stuck in the 2nd databound expression, and the reason is simple: to show that you can call any method on any object you are databinding to, not just the basic ToString() call. These are strongly typed calls to fully-fleged objects, so you can call anything you could call in your codebehind.

That is pretty cool Wyatt, but what if I want to have some logic in there?

Then you need to meet our new friend, the ternary operator:

<p>Daylight savings time <%# CurrentDateTime.IsDaylightSavingTime() ? "is" : "is not" %> in effect.</p>

This is a very handy bit of syntactic sugar that lets one compress a simple if statement down to a single line. The above example would translate to:

private string GetDaylightSavingsStuff()
{
    if (CurrentDateTime.IsDaylightSavingTime())
    {
        return "is";
    }
    else
    {
        return "is not";
    }
}

You could also use this tactic to set visible properties on server controls. For example, let’s say we wanted to make a little announcement if it is, in fact, a weekend:

<asp:PlaceHolder runat="Server">
    <p>The time is now <%# CurrentDateTime.ToString() %>.</p>
    <p>Daylight savings time <%# CurrentDateTime.IsDaylightSavingTime() ? "is" : "is not" %> in effect.</p>
    <p runat="Server" visible='<%# CurrentDateTime.DayOfWeek == DayOfWeek.Saturday || CurrentDateTime.DayOfWeek == DayOfWeek.Sunday ? true : false %>'>
        ITS THE WEEKEND! What are you doing coding man!
    </p>
    <p runat="server" visible='<%# CurrentDateTime.DayOfWeek == DayOfWeek.Saturday || CurrentDateTime.DayOfWeek == DayOfWeek.Sunday ? false : true %>'>
        ITS A WEEKDAY! Get back to work man!
    </p>
</asp:PlaceHolder>

Now, at this point, you are wondering exactly what to do in your templated controls, such as the Repeater or the GridView. And, for that gem of knowledge, you should stay tuned for DataBinding Protips Part 2: Using DataBinder.Eval for Fun and Profit.

Want to play with the code used for the examples above? Get the codes man.

kick it on DotNetKicks.com if you like it.

This article provided by sitepoint.com.

The love birds Shahid and Kareena are back with their new movie ‘Jab We Met’. The stars are very excited about their movie and have lot of expectations from it. The story is very very filmy. It is mainly a sweet and cute love story. The story is about a character Geet played by Kareena […]

HomeHero Fire Extinguisher

It is important that every home should have at least one fire extinguisher, but somehow the huge red tank isn’t exactly easy on the eyes. The HomeHero Fire Extinguisher does away with the ugly and introduces a modern design that you wouldn’t mind having it complement your living room. Features include an ergonomic grip for a more intuitive operation along with a highly visible red safety pin on the back for easy removal. A rubber foot located at the bottom prevents it from scratching your precious marble floor or countertops. No word on pricing, but the HomeHero Fire Extinguisher can be found exclusively at Home Depot when released.

Permalink | Comment | Uberbargain | Uberphones

Filed under: ,

an image of a sun printed on a napkin
There’s been all sorts of debate these days over whether restaurant critics should even attempt to remain anonymous. It started with the outing of Philadelphia Inquirer critic Craig LaBan, but then continued with Danyelle Freeman, the blogger-turned-critic for the New York Daily News (her picture is all over the internet). Does the visual identity of a restaurant critic need to be concealed them to be able to do their job effectively? Many are weighing in on the debate these days, what do you, oh wise Slashfood readers, think?

Permalink | Email this | Comments

Filed under:

At Kaz Hirai’s keynote speech, there were only a few, erm, key announcements made. One of these was the DualShock3. Another was the expanded remote play presentation and a third was the delay of Home. Another tidbit worth mentioning is Sony’s acquisition of Evolution and BigBig Studios, makers of MotorStorm and Pursuit Force, respectively. These are part of Sony Computer Entertainment Worldwide Studios now and will be overseen by Phil Harrison.

Philly H released this statement regarding the acquisition: “Our strategy is to create the best games by working with the best talent and Evolution and Bigbig are world-class additions to our team … The incredible people in these studios further extend the depth and skill of the industry’s largest platform-exclusive development resource.” We’re glad to hear it and expect to hear new games coming from Evolution Studios soon. BigBig is releasing their second Pursuit Force game on the PSP at the beginning of October.

Read | Permalink | Email this | Linking Blogs | Comments

Filed under: , , ,

friends and sex taking a back seat to the web for many americans

The Internet has become so ingrained in our lives that a full fifth of Americans admit to having less sex so they can spend more time online. Those 20 percent happen to be the most extreme cases, but have we become a nation of connectivity addicts?

A survey conducted by advertising agency JWT aimed to find out exactly how reliant Americans are on their Internet connections and mobile phones. The study found that we cannot pull ourselves away from the safety of a broadband connection for too long. Some highlights include:

  • 15 percent of Americans say they can survive just a day or less without the Internet.
  • 21 percent say they last a “couple of days” until digital starvation.
  • 19 percent go a “few” days without it.
  • One fifth say they can stay offline for a whole week — the same number who are willing to give up sex for MySpace and blogs.

According to Ann Mack, Director of Trend Spotting (her title, not ours) at JWT, Americans feel anxious and disconnected when away from their Internet connections. Forty-eight percent percent say they feel something important is missing when they are offline and 28 percent say they spend less time socializing face-to-face because of the amount of time spent online.

We know that Internet addiction is becoming a problem — we just didn’t know it was this wide spread. Obviously we love the Internet as much as everyone else (how else would you read us with out it?), but trust us, sex and face-to-face interaction with other people is much more fun than making sure you reply to that comment on your blog.

From iTnews

Related links:

 

Permalink | Email this | Linking Blogs | Comments

I’ve shown Doug Savage’s great Savage Chickens comic here before, but Doug has outdone himself this time. He decided to enter a music video contest for Laura Veirs, even though he only had 12 days until the deadline and no prior animation experience.

After 500 chicken drawings (equal to his entire comic output over the past two years!), a sore arm, callused finger, and an injured back from leaning over the tripod so much, Doug submitted this great stop-motion animation:

(if you can’t see the video, click here)

Filed under: , , , ,

Google (NASDAQ:GOOG) presentationIt’s been a long time coming, but Google, Inc.’s (NASDAQ: GOOG) “Presentation” web-based presentation application is now available. As always, some are billing it as a “PowerPoint killer,” which is Microsoft, Inc. (NASDAQ: MSFT)’s ubiquitous presentation software that is the lifeblood of business people all over the globe. Google’s already unleashed its word processor and spreadsheet software to the masses (as well as email services, of course), so the presentation portion of the Google Apps package was eagerly awaited, if for nothing more than fodder for comparison to Microsoft’s PowerPoint by the media.

Much like the freely available OpenOffice software suite, Google Presentation can import and use Microsoft PowerPoint files, has built-in themes, text formatting and so forth. Google Presentation, of course, has built-in online collaboration and sharing, which is something many PowerPoint users probably would love to see instead of having multiple versions of the same presentation floating around on the corporate server somewhere. Google’s connective collaboration is the single-largest jump it has over locally installed software packages. On features, however, it lags behind. But, would a customer rather have tons and tons of rarely used features or a way to have a team contribute to a single presentation, even if they were dispersed all over the globe?

E-mailing a link to an online presentation
is a great feature of Google’s new Presentation offering, although services like WebEx have done this with PowerPoint for years. But, emailing a link instead of having folks login to a secure website is a tad easier on all concerned, right? Once Google Presentation gets out in the wild during the rest of this year, the pundits will surely answer that question. We’ll be listening.

 

Read | Permalink | Email this | Linking Blogs | Comments

Filed under: , , , , ,

I have to be honest with you; there probably is about a zero chance that I will be watching National Secrets: Book of Secrets when it hits theaters on December 21st. Frankly, I was pretty surprised that the first film had enough of a following to even warrant a sequel. But, far be it for me to spoil anyone else’s fun; so I present to you Disney’s brand new website for the adventure flick. In the spirit of mystery, I won’t ruin the surprise, but, basically it’s exactly what you would expect. There are plenty of; downloads, trailers, photos, games, and of course, the promise of more to come. Back in May, there had been a teaser poster and just last August, we finally got our trailer. So I can only assume that the web site is the last piece in Disney’s marketing puzzle.

NT 2: Book of Secrets, brought back director Jon Turteltaub, and members from the original cast have also returned. Joining Nicholas Cage will be Diane Kruger and John Voight. Cage has been attached to a variety of roles this year - everything from Al Capone to Magnum P.I. and Liberace, although to be fair most of those projects have fallen by the wayside — it makes you wonder what it was precisely about a National Treasure sequel inspired Cage to stick around. For NT2, Cage’s treasure hunter, Benjamin Franklin Gates is uncovering the truth behind the Lincoln assassination through the diary of his killer, John Wilkes Booth. Basically, it’s another conspiracy flick that’s trying to make US landmarks and history just a little sexier — which as any high school teacher can tell you, is no easy task.

Read | Permalink | Email this | Comments

Filed under:

Citing sources at “Taiwan handset makers,” DigiTimes is reporting that “Google will definitely launch its own branded handset.” However, the Googlephone’s OS, hardware specs, production contractor and operating partners have still not been finalized. Given that we’re already pretty sure that Google has developed their own mobile OS based on Linux, we’ll assume that their use of “finalized” refers to the final feature set and UI polishing — not the possibility of the gPhone running Symbian or WinMo, for example. DigiTimes’ sources also note that Google is contemplating going with a 3G handset instead of EDGE for its initial foray into the cellphone market. However, the choice for Qualcomm’s 3G versus TI’s EDGE could push the introduction of the HTC manufactured handset into the first half of 2008. Come on Google, it’s post-Labor Day now so just go ahead and announce your plans already. We’re big boys, we can take it.

 

Read | Permalink | Email this | Comments

Office Depot Featured Gadget: Xbox 360 Platinum System Packs the power to bring games to life!

Close
E-mail It