Monday, December 25, 2006

ASP.NET AJAX Tabbed Dialog

For this Tabbed Dialog, you are going to need a MultiView, 2 View and 2 LinkButton. Of course, you can add more controls. I 'm planning to make a templated control so I would like to receive comments.

I read these articles before:
HTML Tabbed Dialog Widget
Web Parts - How to create a tabbed view

The templates
<asp:scriptmanager id="sm1" runat="server">
</asp:scriptmanager>

<asp:UpdatePanel id="up1" runat="server">
<contenttemplate>
<div class="tabs">
<asp:LinkButton
id="tab0" runat="server" CommandArgument="0" CssClass="tabheader"
OnCommand="SearchTab_Command">Basic Search</asp:LinkButton><asp:LinkButton
id="tab1" runat="server" CommandArgument="1" CssClass="tabheader"
OnCommand="SearchTab_Command">Advanced Search</asp:LinkButton>
</div>
<div class="tabcontent">
<asp:MultiView id="MultiView1" runat="server" ActiveViewIndex="0">
<asp:View ID="View1" runat="server">
<div class="tabbody">
<asp:Label ID="Label1" runat="server" Text="Tab 1"></asp:Label>
<br />
<asp:Button ID="Button1" runat="server" Text="Post 1" />
</div>
</asp:View>
<asp:View ID="View2" runat="server">
<div class="tabbody">
<asp:Label ID="Label2" runat="server" Text="Tab 2"></asp:Label>
<br />
<asp:Button ID="Button2" runat="server" Text="Post 2" />
</div>
</asp:View>
</asp:MultiView>
</div>
</contenttemplate>
</asp:UpdatePanel>

The code
<script runat="server" type="text/VB">
Private Sub SwitchCss(ByVal wctl As WebControl)
Dim cc As String = IIf(wctl.CssClass.Equals("tabheader"), "tabheader_active", "tabheader")
wctl.CssClass = cc
End Sub

Protected Sub SearchTab_Command(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.CommandEventArgs)
Dim ctl As WebControl

ctl = CType(up1.FindControl(String.Format("tab{0}", MultiView1.ActiveViewIndex.ToString())), WebControl)
SwitchCss(ctl)

MultiView1.ActiveViewIndex = e.CommandArgument

ctl = CType(sender, WebControl)
SwitchCss(ctl)
End Sub

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
If (Not IsPostBack) Then
SwitchCss(tab0)
End If
End Sub
</script>

The CSS
.tabheader {
background-color: #F5F5F5;
color: #C0C0C0;
border: solid 1px #C0C0C0;
}

.tabheader_active {
background-color: #FFFFFF;
color: #608fc8;
border: solid 1px #C0C0C0;
border-bottom: solid 1px #FFFFFF;
cursor:default;
}

.tabs a {
position: relative; width: auto; display:inline;
padding: 2px 4px 2px 4px;
margin: 0 0 0 5px;
font-size:10pt;
}

.tabs a:hover { text-decoration:underline; }
.tabs a.tabheader { color: #666666; }

.tabcontent {
height: 100%; margin-top:2px;
background-color: white;
border: solid 1px #D3D3D3;
}

.tabbody { height: 100%; margin: 9px 9px 9px 9px; }

Sunday, December 17, 2006

Windows AutoPlay Problem

After I installed Nero, I noticed AutoPlay wouldn't start. What was the problem?. My coworker Ruben gave me a self tip. Greetings Respaq.

Look this article:
Autoplay Repair Wizard

Wednesday, December 13, 2006

Tunning your Code for Performance

When I get a problem about performance issue, The first thing I think are review: loops, comparison and assignments sentences, depending of the kind of project.

In other words:
- Boxing/Unboxing
- Value Types (String, Int, Struct, Class, etc)
- Loops (For each, While, etc)
- Comparison(==, !=, Equals, etc)
- Database Access Topics (DataSet, DataReader, CommandType)
- Exception Handling (Based in Values, Try...Catch)
- Multithreading

I read these articles before:
Effective C# - Performance notes
Performance Tips and Tricks in .NET Applications

Saturday, December 09, 2006

XSLT Templates

If you need to add format for display transformation, you can use XSLT templates.

Numeric Templates
<xsl:template name="currencyValue">
<xsl:param name="Number" />
<xsl:value-of select="format-number($Number,'#,###,##0.00')" />
</xsl:template>

<xsl:template name="integerValue">
<xsl:param name="Number" />
<xsl:value-of select="format-number($Number,'####0')" />
</xsl:template>

For invoke them
...

<xsl:variable name="totalRows" select ="count(reg/amount)" />
<xsl:variable name="totalCustomer" select ="sum(reg/amount)" />
...

<xsl:call-template name="currencyValue">
<xsl:with-param name="Number" select="$totalCustomer" />
</xsl:call-template>
...
<xsl:call-template name="integerValue">
<xsl:with-param name="Number" select="$totalRows" />
</xsl:call-template>
...
The ouput
2,333.01
561

Your Gmail Account as SMTP Server, ASP NET 2.0

It's gorgeous, when you don't lose time to configure SMTP Server for a simple test. You could use your Gmail Account, to do it.

I read this article before:
Configuring other mail clients
Sending Email with System.Net.Mail
How to use System.Net.Mail.SmtpClient via SSL and Authentication?

Well for accomplish that, first adjust your web.config...

<system.net>
<mailsettings>
<smtp>
<network host="smtp.gmail.com" port="587" username="youraccount@gmail.com" password="yourpassword" defaultcredentials="false">
</network>
</smtp>
</mailsettings>
</system.net>


You write a few lines...

MailMessage message = new MailMessage();

message.From = new MailAddress("sender@domain.com");
message.To.Add(new MailAddress("destination@domain.com"));
message.Subject = "The subject";
message.Body = "The content";

SmtpClient client = new SmtpClient();
client.EnableSsl = true;
client.Send(message);


And run it.

Tuesday, December 05, 2006

Creating Custom WorkFlow for WSS 3.0

For create custom WorkFlow for WSS, in this case with Visual Studio 2005, you need the download:
Workflow Developer Starter Kit for WSS 3.0

Of course, you need too, WSS 3.0 running on Windows Server 2003.

Initial walkthrough
Creating WSS 3.0 Workflows with Visual Studio 2005

Saturday, December 02, 2006

DNN Custom Module

I recently developed a DNN Custom Module; by the way it doesn't very difficult. It's very explained. Basically, you use an ASCX and invoke a DNN's DAL Libraries for perform the data extraction.

I read this article before:
http://www.adefwebserver.com/DotNetNukeHELP/DNN_Module4/

Open Sources in C#

All open sources as you would imagine in C#. It's like a directory, in addition you could suggest other projects.

http://csharp-source.net/

Any messenger, anywhere

Meebo for Free is an interesting website for instant messaging. You can use Aim, Yahoo Messenger, Gtalk, MSN Messenger and ICQ as one. This was a tip of my coworker Miguel; greetings!

http://www29.meebo.com/index-en.html
Google