Salvo Davide Rapisarda

Italian developer thinks.
The Daily WTF - Curious Perversions in IT

 

I'm studing for MCPD exam from the training kit book and I get this link on page 227

http://thedailywtf.com/Articles/Journey_to_the_Center_of_the_Database.aspx

It's a very funny story and a very funny site.

Function Parameter Constraint

As a developer every day I find myself in situations where I have to write different methods for purposes of any kind.  Generally, I write methods that take into one or more input parameters and return a particular result

Problems arise when my colleagues use the methods that I write. In particular, the biggest problems occur when they are specified in input values that are not valid for the execution of method.

Ok. I know that I can test each parameter before the execution of the real first instruction but it's a very frustration for a developer like me.

I think that can be nicely to have a mode for define at syntax level a constraint for a parameter of a method.

Something like :

<BetweenContraint(i,0,100)> _
Public Function TakeIntegerBetween0And100(ByVal i As Integer)

There is already something like this or I invented the wheel?

I know only looking for on Google or with a comment of some blog reader.

I have got Microsoft Usb Key

I have got Microsoft Usb Key during presentation of new Microsoft products in Catania (Sicily - Italy) last 18 March.

MUSBKEY

It's a 2 GB memory. I tried to use it with Ready Boost feature of Windows Vista but does not work.

Posted: Apr 06 2008, 01:50 PM by Blackat.NET | with no comments
Filed under:
I have installed Windows Live Writer

Tonight I have intalled Windows Live Writer. It's a great tools for write some posts on my blog.

I promise to me to write some content on next week...:-P

Merry Christmas!!!

 

Posted: Dec 23 2007, 01:37 PM by Blackat.NET | with no comments
Filed under:
This Monday I have passed the 70-528 exam

Alleluja!!! ^_^

How to clean ID's on HTML output for server control in ASP.NET

Problem:

If you have a server control like Label or Image with a long name ID attribute when it's render as html the attribute ID is render on HTML output. If you have a lot of this controls on a web page this can introduce an overhead.

Solution

The first solution is to remove the ID on control. Like this :

<asp:Label  runat="server" Text="Salvo" ></asp:Label>

It work...but you can't use designer with visual studio because visual studio don't know the name of your label.

Then...this is not a good solution .

The second solution is to set ID with nothing (or null for C# programmers) at PreRender stage. Like this :

<script runat="server">

    Protected Sub DeleteID(ByVal sender As Object, ByVal e As System.EventArgs)
        If TypeOf sender Is Label Then
            Dim l As Label = sender
            l.ID = Nothing
        End If
    End Sub
</script>

<asp:Label ID="MyLongIDLabelForName" runat="server" Text="Salvo" OnPreRender="DeleteID"></asp:Label>

This is a good solution. :-) 

 

 

Posted: Nov 09 2007, 11:08 AM by Blackat.NET | with 3 comment(s)
Filed under:
Prompt Control

I have been doing a little experiment with custom control in asp.net. So, I think...what I can do if I have a web page where I can't put a textbox ? Simple, the solution to my problem is the javascript prompt function. So, I'v created a simple control for prompting where a user click a text.

The code of prompt control:

Imports Microsoft.VisualBasic

Namespace Salvo

 

Public Class PromptControl

Inherits System.Web.UI.WebControls.HyperLink

Implements IPostBackEventHandler

Public Event Prompt(ByVal sender As Object, ByVal e As String)

Public Property Message() As String

Get

Return ViewState("PromptMessage")

End Get

Set(ByVal value As String)

ViewState("PromptMessage") = value

End Set

End Property

Public Sub New()

MyBase.New()

End Sub

Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)

Page.ClientScript.GetPostBackEventReference(Me, "")

Me.Attributes.Add("onclick", "__doPostBack('" & Me.ClientID & "',prompt('" & Message & "'));")

MyBase.Render(writer)

End Sub

Public Sub RaisePostBackEvent(ByVal eventArgument As String) Implements System.Web.UI.IPostBackEventHandler.RaisePostBackEvent

RaiseEvent Prompt(Me, eventArgument)

End Sub

End Class

End Namespace

 

The code of web page:

<%@ Page Language="VB" %>

<%@ Register Namespace="Salvo" TagPrefix="SA" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

Protected Sub AlertMe(ByVal sender As Object, ByVal message As String)

Page.ClientScript.RegisterStartupScript(Me.GetType, "promptMessage", "alert('What you have typed in prompt is " & message & "');", True)

End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title></title>

</head>

<body>

<form id="form1" runat="server">

<div>

<SA:PromptControl runat="server" ID="A" Text="Prompt me" Message="Input what you want!" OnPrompt="AlertMe" ></SA:PromptControl>

</div>

</form>

</body>

</html>

 

Web Developer's Handbook

If you are a web programmer the follow link can help you when it's time to design your web application.

http://www.alvit.de/handbook/

You can find a collection of links about CSS, JavaSript, Accessibility, ecc... 

For me it's very very helpful.

 

Posted: Nov 03 2007, 03:19 PM by Blackat.NET | with no comments
Filed under:
My first blog!!

Aaaaahhhhh!!! I'm really happy to write my first blog post!!

Thanks to Joe Stagner!!! ^_^

 And now at work!!!
 



 

More Posts