Wednesday, March 21, 2007

Developing SEO friendly URLs with ASP NET 2.0

very simple and clear overview how to develope it.

Wednesday, March 14, 2007

surprise: int.TryParse(xx,yy)

I really get surprised about the following behaviour:

when I've tried to use the follwoing line of code:

if(!int.TryParse(row["myRowName"] as string, out myDefinedInt))

tryParse always returned me false and I assinged a default value. After making sure that all my rows have values for myRowName I were confused.

a friend suggested to use row["myRowName"].ToString() and voila it worked like i wanted.

I didn't really figured out why that happens, then in none of my cases the value were empty that my expression as string would return null.

here a bit more code:

DataSet data = DataReader.GetData();
DataTable tab = data.Tables["MyTableName"];
DataView view = tab.DefaultView;

view.RowFilter = "RowNameA LIKE '%" + valA + "%' AND RowNameB LIKE '%" + valB + "%'";

if (view.Count > 0)
{
Data.MyDataObject item;
foreach (DataRowView row in view)
{
item = new Data.MyDataObject();
item.SomeValue1 = row["SomeValue1"] as string;
item.SomeValue2 = row["SomeValue2"] as string;
int outData = -1;
if (!int.TryParse(row["SomeValue3"].ToString(), out outData))
{
item.SomeValue3 = 40;
}
else
{
item.SomeValue3 = outData;
}

etc ... etc ... etc ...

Thanks to richi (Y)

Saturday, March 10, 2007

How To: Implement your email sending with the asp:PasswordRecovery control

after a while i finally figured out what i have missed to prevent emails to sent twice - once over the control and once over my own logic.

Markup:

<asp:PasswordRecovery
ID="PasswordRecovery"
runat="server"
OnSendingMail="PasswordRecovery_SendingMail"


Code Behind:

protected void PasswordRecovery_SendingMail(object sender, MailMessageEventArgs e)
{
e.Cancel = true;
e.Message.Dispose();

.. here my own logic starts.
}

in the web.config file you need minimum the following configuration:

<system.net>
 <mailsettings>
  <smtp from="your email address">
 </mailsettings>
 </system.net>
</configuration>

.. evoila.. that's all - happy email sending.

Friday, March 09, 2007

net use and error messages

the msdn bible contains everything:

System Error Codes

The following topics provide lists of system error codes. These values are defined in the WinError.h header file.







enjoy it.

Shared Cache - .Net Caching made easy

All information about Shared Cache is available here: http://www.sharedcache.com/. Its free and easy to use, we provide all sources at codeplex.

Facebook Badge