Monday, August 18, 2008
SCRIPTSTER. East Java Baker: GridView Delete, with Confirmation
GridViewRowEventArgs e
{
if e.Row.RowType DataControlRowType.DataRow
{
LinkButton l LinkButton e.Row.FindControl LinkButton1 ;
l.Attributes.Add onclick , javascript return +
CONFIRM Are you sure you want to delete this record +
DataBinder.Eval e.Row.DataItem, CategoryID + ;
}
}"
Wednesday, July 30, 2008
Logging HTTP Referals with ASP.NET
public void Application_OnPostRequestHandlerExecute(Object sender, EventArgs e)
{
ReferralLogger rlLogger;
if (String.Empty != Request.QueryString.ToString())
// We have query parameters so we need to log those as well
// as the current page name
rlLogger = new ReferralLogger(Request.Path.ToString()+"?"
Request.QueryString.ToString(),
Request.UrlReferrer);
else
// No query string, so simply log the request and the referring URL
rlLogger = new ReferralLogger(Request.Path.ToString(),
Request.UrlReferrer);
}
And now, every time the ASP.Net engine displays a file its referral information will be stored in your database.
Tuesday, July 22, 2008
the future is dynamic with Python
Dynamic Injector Mechanism
The compilation model for dynamic languages enables you to use simple syntax into which additional code is injected at run time. For example, you might have code that reads a value from the query string. The URL for the page might look like this:
http://someserver/somepage.aspx?MyValue=17
In a C# page, you can use the following code to obtain the value:
String myValue = Request.QueryString["MyValue"];
The dynamic injector mechanism allows you to write much simpler code in dynamic languages, as shown in the following examples:
myVar = Request.MyValue
The support code for dynamic languages enables the registration of an object referred to as an injector. By registering as an injector, the object agrees to handle code that matches a certain pattern. For example, if the dynamic language engine is unable to resolve the expression SomeObj.SomeName
, where SomeObj
is an HttpRequest
object and SomeName
is not a real property of the HttpRequest
object, the engine calls the injector that has been registered to handle that pattern. The injector handles the expression by calling SomeObj.QueryString["SomeString"]
. The net effect is exactly the same, but the syntax is much cleaner.
The injector mechanism has many potential uses. For example, wherever you would write SomeControl.FindControl("SomeChildControl")
in C#, you can write SomeControl.SomeChildControl
in a dynamic language application. The mechanism is extensible and can be applied to any collection that is indexed by strings.