Microsoft Study Bible

December 17, 2009

Linq statement in Asp.net

Filed under: Developer tools and applications — Tags: , , , , — Jackson @ 4:58 am

If it is in desktop, you just need to

_context.Log = Console.Out;

You just input SQL statement in the console .So, what about in Asp.net?

I want to try to use StringWriter. We can use it to replace Console.Out to help us receive the output log, and save the log in StringBuider.

So, construct an auxiliary class

using System;

 using System.Collections.Generic;

 using System.Linq;

 using System.Web;

 using System.IO;

 using System.Text;

 namespace Clowwindy.Models

 {

 public static class LogHelper

 {

 public static StringBuilder Log = new StringBuilder();

 public static TextWriter In = new StringWriter(Log);

 public static string GetAllLog()

 {

 In.Flush();

 return Log.ToString();

 }

 public static void Clean()

 {

 Log = new StringBuilder();

 In = new StringWriter(Log);

 }

 }

 }

 Add another page log.aspx to display the log

 <%@ Page Language=”C#” AutoEventWireup=”true”

 CodeBehind=”Log.aspx.cs” Inherits=”Clowwindy.Log” %>

 <!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>SQL Log</title>

 </head>

 <body>

 <form id=”form1″ runat=”server”>

 <asp:Button ID=”btn_Clean” runat=”server” Text=”Clear out”

 onclick=”btn_Clean_Click”/>

 <div>

 <asp:Literal ID=”Literal1″ runat=”server”></asp:Literal>

 </div>

 </form>

 </body>

 </html>

 using System;

 using System.Collections.Generic;

 using System.Linq;

 using System.Web;

 using System.Web.UI;

 using System.Web.UI.WebControls;

 using Clowwindy.Models;

 namespace Clowwindy

 {

 public partial class Log : System.Web.UI.Page

 {

 protected void Page_Load(object sender, EventArgs e)

 {

 if (Request.UserHostAddress != “127.0.0.1″)

 {

 Response.End();

 return;

 }

 Literal1.Text = LogHelper.GetAllLog().Replace(”\n”,”\n<br/>”);

 }

 protected void btn_Clean_Click(object sender, EventArgs e)

 {

 LogHelper.Clean();

 Literal1.Text = null;

 }

 }

 }

Finally, in the places where new DataContext is, Add _context.Log = LogHelper.In:

public Repository()

 {

 _context = new TDataContext();

 _context.Log = LogHelper.In;

 }

Open log.aspx, you will see the previous SQL statements.

December 7, 2009

How to pass parameters between Asp.net pages

Filed under: Server technologies — Tags: , , , , — Jackson @ 5:28 am

 There are many methods to pass parameters between pages, including Get, Post, Session, and Application。However,there are some new and unique methods in Asp.Net.
The page B wants to take the value from Page A. (more…)

December 2, 2009

How to achieve image zoom in WPF ?

Filed under: Developer tools and applications — Tags: , , — Jackson @ 5:03 am

Here is a question! I need to perform a zoom on an image, how can I do this? Here, we’ll introduce a way to achieve image zoom by using the mouse in WPF.

Here is the key code.

XAML code: (more…)

Error LNK2001 (C++)

Filed under: Server technologies — Tags: , , , , — Jackson @ 4:58 am

Would you have such an experience: you try to build program in C++ code. All of the code is simple and legal, however, when you compile link with your programs, the following link errors happen:

>error LNK2001: unresolved external symbol _purecall (more…)

Powered by WordPress

Close
E-mail It