Tuesday, December 30, 2008

File v/s BLOB storage in applications

This is my one of the old articles on File storage in applications. May help some readers..
http://www.codeproject.com/KB/database/File_Vs_Blob_Storage.aspx

BLOB Storage in SQL Server. How to store and retrive BLOBS in asp.net application

I have written an article on how to work on BLOB objects in asp.net and sql server. This may help the novice application developers.

http://www.codeproject.com/KB/database/Store_and_manipulat_BLOBs.aspx

-:HTH:-

How to improve site performance by compressing ViewState ?

Here is an article that describes how to improve aspnet site peroformance by compressing viewstate. Worth reading...http://www.dotnetbips.com/articles/22d33d11-1a75-42c8-bbf6-ca1a345d3fcf.aspx

Best ASP.NET FAQ for interviews

Here are some useful links...

http://www.syncfusion.com/faq/aspnet/

http://www.aspnetfaq.com


http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=4081&lngWId=10

http://www.techinterviews.com/?p=193

http://blogs.crsw.com/mark/articles/254.aspx

Shopping Cart Web Template

Here is a nice shopping cart web template..Take it up from there...
http://demo.x-cart.com

:)

Another free CSS web template

This will help the beginners to start with the simple site design and layouts..
Grab it..
http://www.free-css-templates.com

Mini icons for your web applications....

Here are some nice icons which we can use it inside the controlsa and for CSS while developing web applications...

http://icons.primail.ch/

Digg it....

Disaster Recovery in SharePoint Products and Technologies 2003

The below informations will help you a lot when you start managing the SharePoint server farm of your organization since failure is not an option for us (IT) !

This URL points to a page on TECHNET that may interest you:
http://technet.microsoft.com/en-us/library/cc750142.aspx

How to perform a disaster recovery operation of Windows SharePoint Services 2.0 Companyweb and Windows SharePoint Services 2.0 databases?
http://support.microsoft.com/default.aspx/kb/827701

Move SharePoint sites across server farm
http://blogs.msdn.com/priyo/archive/2006/03/24/559896.aspx

I thought this Help and How-to article from Microsoft(R) Office Online might interest you. "Back up, restore, or move a SharePoint site"

-::HTH::-

Ajax pre-loader image online generator

Here we go!...http://www.ajaxload.info/
You can have your own ajax pre-loader...build your own styles..

Ziyad

Here is a joke!

Long back, a person who sacrificed his sleep, forgot his family, forgot his food, Forgot laughter were called "Saints", But now they are called.. "IT professionals"

Monday, December 29, 2008

Happy Holidays !

Dear readers,
I wish you all Merry Christmas, Happy New Year and Happy Holidays !

Rgds, Z

Tool to generate CSS Menu, CSS Button, CSS Page Layout, etc. and free template

Hey developers, here is the nice tool to create your own CSS driven menu, web page layout, button and nice site template for free...

http://www.cssportal.com/

Hope this will help us in our work...

Sunday, December 28, 2008

How to render RDLC (local report) as excel in asp.net ?

Here we go - to render the rdlc local report in asp.net web application


public static void GenerateExcelFromLocalReport()
{
//get your report datasource from the database
IDataReader iReader = GetReportDataSourceReader();
LocalReport report = new LocalReport();
report.ReportPath = HttpContext.Current.Server.MapPath("~/reports
/rdlc/MyReport.rdlc");

report.DataSources.Add(new ReportDataSource("DataSource1", iReader));
ReportParameter[] parameters = new ReportParameter[3];
parameters[0] = new ReportParameter("Filter1", "Filter1's value"));
parameters[1] = new ReportParameter("Filter2", "Filter2's value");
parameters[2] = new ReportParameter("Footer", "Footer's value");
report.SetParameters(parameters);
//
//code to render report as excel document
string encoding = String.Empty;
string mimeType = String.Empty;
string extension = String.Empty;
Warning[] warnings = null;
string[] streamids = null;
//
byte[] byteArray = report.Render("Excel", null, out mimeType,
out encoding, out extension, out streamids, out warnings);

//
HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";
HttpContext.Current.Response.AddHeader("Content-Disposition",
"attachment; filename=MyExcel.xls");

HttpContext.Current.Response.AddHeader("Content-Length",
byteArray.Length.ToString());

HttpContext.Current.Response.ContentType = "application/octet-stream";
HttpContext.Current.Response.BinaryWrite(byteArray);
HttpContext.Current.Response.End();
}


-::HTH::-

How to generate or render .pdf document from local report (rdlc) with parameters ?

Here is the code to render the rdlc (local report) as pdf document in asp.net web application.

public void GeneratePDFFromLocalReport()
{
//get your report datasource from the database
IDataReader iReader = GetReportDataSourceReader();
LocalReport report = new LocalReport();
report.ReportPath =
HttpContext.Current.Server.MapPath("~/reports/rdlc/MyReport.rdlc");
report.DataSources.Add(new ReportDataSource("DataSource1", iReader));
ReportParameter[] parameters = new ReportParameter[3];
parameters[0] = new ReportParameter("Filter1", "Filter1's value"));
parameters[1] = new ReportParameter("Filter2", "Filter2's value");
parameters[2] = new ReportParameter("Footer", "Footer's value");
report.SetParameters(parameters);
//
//code to render report as pdf document
string encoding = String.Empty;
string mimeType = String.Empty;
string extension = String.Empty;
Warning[] warnings = null;
string[] streamids = null;
//
byte[] byteArray = report.Render("PDF", null,
out mimeType, out encoding, out extension, out streamids, out warnings);
//
HttpContext.Current.Response.ContentType = "Application/pdf";
HttpContext.Current.Response.AddHeader("Content-Disposition",
"attachment; filename=MyPDF.pdf");
HttpContext.Current.Response.AddHeader("Content-Length",
byteArray.Length.ToString());
HttpContext.Current.Response.ContentType = "application/octet-stream";
HttpContext.Current.Response.BinaryWrite(byteArray);
HttpContext.Current.Response.End();
}


-::HTH::-

Friday, October 17, 2008

Error while binding databound control in asp.net. "Eval(), Bind() can only be used in the context of a databound control"

Did you ever get a message "Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control" while binding a databound control ?

If you ask me this question, my answer is Yes, i did receive the above message when i tried binding a dropdownlist template column inside the gridview control in asp.net 2.0. I was surprised seeing the message hitting me all the rack and was curious to see the issue in detail.
I had already done the binding of template column (drop down) in the row item created event.

Upong further investigarion i came to know that there is a difference between <%#Eval("field_name") %> and <%# Databinder.Eval("filed_name") %>

In the Eval(), ASP.net resolves the object to which databinding is done where as in the Databinder.Eval() since we give the target object manually, ASP.net has nothing to resolve.

So the resolution is use <%# Databinder.Eval("filed_name") %> instead <%# Eval("field_name") %>

Friday, September 19, 2008

Cannot create/shadow copy <your assembly file> when that file already exists

Cannot create/shadow copy < your assembly file dll > when that file already exists

When you compile the web projects in visual studio 2005/2008, you may receive the above message. 
And in order to get rid of this, you can either kill the process aspnet_wp.exe using the task manager 
or add the following tag in the web.config inside system.web tag.

<hostingEnvironment shadowCopyBinAssemblies="false" />

Although the former resolution is just a temperory fix, the later one will fix this issue for that 
project permanantly.

-::-

Monday, September 15, 2008

Javascript to limit characters (length) in Text Area or Multiline TextBox

Bind the below function to keypress event as below

txtJustification.Attributes.Add("onkeypress", "return limitText('" + txtJustification.ClientID + "', 3000);");

function limitText(limitField, limitNum)
{
var obj = document.getElementById(limitField);
if (obj.value.length > limitNum){return false;} else return true;
}

Hope this helps

MDI Child Window always on top - Winforms

As MDI Child winform cannot be shown on top by using "BringToFront" or "TopLevel=true" properties. This could be achieved only by setting the property frm.Owner = frmMDI

Hope this helps

OnClientClick and Form Validation in Asp.net

When we use OnClienClick script for a button in asp.net, you can notice that all the associated validation controls (validation group) will fail to validate. This happens because the OnClientClick script overrides form validation script.

To fix this, here is the work around.Add the below code in Page Load event

Button1.Attributes.Add("onclick", "if(confirm('do this ?') == false) return false;");

This will execute the client script and then executes the form validations scripts before post back.

Hope this helps

Friday, September 05, 2008

ASP.NET Menu control not being rendered properly in Google Chrome

Today i tried installing the Google Chrome in my laptop machine. Although it is light and nice in look and rich in features (as usual from Google), it showed some weired behaviour when i open my online applications. Especially the ASP.Net Menu Control was not rendered as is to be.

It does not display the child nodes on hover and when we click any menu item, it then refresh the page with child nodes...

Cause & Resolution

The reason for this weird behaviour is just because the way the menus are rendered in chrome is different from IE and Fire Fox (FF). The recent chrome browser render the <a> component as <div> and <span> . If you look into the view source, you may notice that the menu structure as below.
<div id="ctl00_mainMenu">
<span><a class="ctl00_mainMenu_1" href="Test1.aspx">Menu1</a></span>
<span><a class="ctl00_mainMenu_1" href="Test2.aspx">Menu2</a></span>
<span><a class="ctl00_mainMenu_1" href="Test3.aspx">Mwnu3</a></span>
</div>
It is because of both Internet Explorer and Firefox render the ASP.NET Menu control as <table>--<a> mark up.
However, the rendered mark up for the latest beta version of Google Chrome will be like the following code, the <table> and <a> become to <div> and <span> :
And the best resolution for the subject issue is to ASP.NET 2.0 CSS Friendly Control Adapters 1.0. This adapter will render the ASP.NET Menu in Google Chrome properly
-::-

Wednesday, August 13, 2008

Import Excel into Dataset

To make mass data entry, we seldom use the excel imports in application. This saves time and effort involved in the task. Here is the demonstration how to.?

1. Upload th excel file into Application Server (IIS Site Folder)

FileUpload1.SaveAs(Server.MapPath("~/xcel/") + FileUpload1.FileName);


2. Connect excel sheet, read data and import into a dataset.

DataSet myDataset = new DataSet();
string strConn = @"Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=" + FilePath + @";
Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1""";
OleDbConnection conn = new OleDbConnection(strConn);
conn.Open();
DataTable DTable = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
//here the code will read sheet from spreadsheet with any name --generic
OleDbDataAdapter myData = new OleDbDataAdapter
(@"SELECT * FROM [" +
DTable.Rows[0]["TABLE_NAME"].ToString() + "]", conn);
//
myData.Fill(myDataset);

That is the end. The code is not restricted or limited to any name of the sheet in the excel spread sheet. ....

-::-

Friday, August 01, 2008

CSS text-align:center not working in FireFox (FF)

The CSS style for any component text-align:center will not work in FireFox (FF) browser. The work around is to have the CSS defined as follows. If you defined the below CSS for body, it will work in both IE and FF. You have to defined both CSS for the body as defined below (one after another) to have cross browser compatibiltiy. It will not work if you asssing only text-align: -moz-center;


body
{
text-align: center;
}

body
{
text-align: -moz-center;
}

-::-

Tuesday, July 29, 2008

Javascript to accept only numeric values

Here is the javascript code to accept only numeric values in textboxes. This has to binded to
"onkeypress" event.


function onlyInteger(evt)
{
evt = window.event;
var charCode = evt.keyCode;
if (charCode > 31 && (charCode <> 57)) {
status = "This field accepts numbers only.";
return false;
}
status = "";
return true;
}
-::-

Tuesday, March 11, 2008

Error Creating Control - Formdigest1. Failure decoding embedded permission set object

When you try to host an asp site in different apps server to query the sharepoint engine 2003, you may recieve the error

"Error Creating Control - Formdigest1. Failure decoding embedded permission set object"

while using the Formdigest control.

Formdigest controls is to be used in the pages of web application where in you query and update the sharepoint data via object ibrary. Formdigest validates the security of the page while submitting a request.

Resolution
To make it work, the web apps should be deployed in the same site, i mean in the same context.

-::-

How to enable inline coding in MOSS 2007 or WSS 3.0 Custome aspx pages ?

By default, the inline code would throw error in custom defined aspx pages in MOSS / WSS 3.0. To make it work, add the following lines of code in the web.config.


<PageParserPaths>
<PageParserPath VirtualPath="/<>/*" CompilationMode="Always" AllowServerSideScript="true" IncludeSubFolders="true" />
</PageParserPaths>


The "PageParserPaths" tags would be already existing in web.config. All you need to do is to add the code in between to specify your folders to execute the C# script.

- :: -