Thursday, May 31, 2007

How to handle hidden columns/values in gridview 2.0?

Introduction

It is always a "Fact" that we are not supposed to disclose any confidential data to the browser, whether it is a primary key or not. At the same time we may need those values for further processing of the page logic. In datagrid (.net 1.1), we always used to get the hidden values in the viewstate and we can make use of those values in client side script.


Resolution

However, the situation is changed now!. Due to security breach, microsoft has come up with new term "DataKeys" in order to hide the hidden fields forever (from rendering). You cannot see the hidden column values in View State. At the sametime, you can have multiple datakeys for a particular gridview control. Doing so, you can extract the values of those fields against each row, but only from code behind as it is not rendered in the browser.

You can access the values as below :

GridView.DataKeys[i].Values[j].ToString()
where 'i' represent the rownumber and 'j' represent the index of DataKeys (defined).

-::-

Wednesday, March 14, 2007

Is cross database referential integrity possible ?

Cross database referential integrity is not possible in SQL. Hence deletion of any master data stored in one database will make orphan the related data in other databases (transaction db). Also, if cross – database constrain is possible, then it is more or less similar to saying that you can have PK-FK relation for databases. i.e., you cannot drop a database when there are some PK records for some FK records in the other database. Right? Any thought? Let me know if you find any thing!!


And as per the third party tool, remote-keys this could be achieved. But it is more like a work around, achieving the same programmatically (DDL statements in triggers)


Hence to my knowledge, it is not possible in SQL where as the feature is available in SYBASE. Any different thought ?

What developer says?

http://msdn2.microsoft.com/en-us/library/ms189799.aspx#

http://www.thescripts.com/forum/thread584690.html



What Third Party says?

http://www.remote-keys.com/product.aspx

-::-

Wednesday, February 21, 2007

IE Web User Controls deployment in SharePoint 2003 - How to?

Although Microsoft has stopped support for MS IE Web Controls, we would use it when we need some conrols like TreeView in .Net 1.1 - say sharepoint 2003

Steps
1. Add the controls in .ascx (used for web parts)
2. While deploying, copy the Microsoft.Web.UI.WebControls.dll to the bin of WSS root
3. Deploy the above dll in GAC (if required)
4. Run the Build.Bat file from C:\Program Files\IE Web Controls (installation folder). While doing this, care should be taken for CSC.exe location - either run it from VS.Net Command prompt (after switiching to the above location) or include the path of CSC.exe in the "Environment Variables" of system. This will generate a \build\Runtime folder with script file required for the controls
5. Copy the above folder to the root of WSS
6. Exclude the path for the above folder, say webctrl_client (only type the folder name as it is in the root folder) by configuring the virutal server (use SharePoint Central Administration page)

Now it will work!!

-::-

Tuesday, February 20, 2007

How do we generate XSD in VS.Net for reporting from a stored procedure containing #temp tables (local) ?

In many scenarios we may have to use local temp tables in procedures instead of functions returning tables. Always, temp tables are best in performance. When there is any temp table involved in an sp, say for reporting, VS.Net will not allow you to generate a typed dataset (.xsd) out of that.

Resolution

1. Comment the lines containting temp tables in sp
2. Generate .xsd file in .net IDE
3. Uncomment the comments

Yeah!!! It worked

-::-

Monday, February 12, 2007

How to consume a Share Point web service in ASP.Net web ?

It is always an appreciable effort if we consume an existing system as primary reference instead of storing same data here and there

Follow the steps below:

1. Add web reference in the IDE with URL of SPS site
2. Create a proxy class with WSDL.exe utility (available in the VS.Net Tools menu)
Go to command prompt and type as below
wsdl /out: c:\ProxyClass.cs http://server:90/_vti_bin/lists.asmx
Find more options of wsdl here
3. Consume the webservice via proxy class (shouled be added to the project)
4. Now you should get all the published methods in web service via proxy class

-::-

Sunday, February 11, 2007

Crystal Report prompts for report parameters in VS.Net 2005 after being upgraded (VS.Net 2003)

I got parameter prompts when i run my windows application after upgrading to framework 2.0. The application was built on .net 1.1 and was running successfully

Resolution

Pass the parameter after binding the report document to the report viewer component as below. (I passed it before binding to CRV component in .net 2003)

rptDoc.SetDataSource(ds.Tables[0]);
crv.ReportSource = rptDoc;
rptDoc.SetParameterValue("BRAND", Application.ProductName);

-::-

Saturday, February 10, 2007

Configuration Error - Unrecognized attribute 'xmlns' web.config - ASP.net 2.0

When you try running a ASP.net 2.0 web application, you may receive a web.config error as "Unrecognized attribute 'xmlns'"

Line 1: <?xml version="1.0"?>
Line 2:
Line 3: <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
Line 4:

Reason
Your system/server must be running more than one version of .net framework

Resolution
1. Choose Start -> Control Panel -> Administrative Tools -> Internet Information Services
2. Expand the nodes until you can see your virtual directory
3. Right-click on the virtual directory and click Properties
4. Select the ASP.NET tab
5. Under the ASP.NET version, choose 2.0.50215.0
6. Click OK.

Wednesday, February 07, 2007

VS.Net 2005 Templates not found after applying the patch VS80-KB915364-X86-ENU

You might have surprised seeing no templates when you open the VS2005 IDE after installing the patch VS80-KB915364-X86-ENU

Resolution

Regenerate the templates by running 'devenv /installvstemplates' or reinstall
Visual Studio.
Note: Action requires Administrator privileges.

-::-

SQL Server 2000 installation fails with "...previous program installation..." error message

When you install SQL Server 2000, this error message may occur:

"A previous program installation created pending file operations on the installation machine. You must restart the computer before running setup."

Resolution
1.Run the Windows Registry Editor
2.Go to HKEY_LOCAL_MACHINE\SYSTEM\
CurrentControlSet\Control\SessionManager
3.Delete the pendingfilerenameoperations key

Now it should work!!

-::-

Tuesday, February 06, 2007

File upload size limitation in <asp:FileUpload> control

You may receive surprise results when you try to upload a file of size more thatn 4mb with <asp:FileUpload> control

You may not realize it, but there is a limit to the size of a file that can be uploaded using this technique. By default, the maximum size of a file to be uploaded to the server using the FileUpload control is around 4MB. You cannot upload anything that is larger than this limit.

To change this size limit, you make some changes in either the web.config (found in the ASP.NET 2.0 configuration folder at C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG) or your application's web.config file.

In the web.config file, find or add a node as following inside System.Web tag:

<httpRuntime
executionTimeout="110"
maxRequestLength="4096"
requestLengthDiskThreshold="80"
useFullyQualifiedRedirectUrl="false"
minFreeThreads="8"
minLocalRequestFreeThreads="4"
appRequestQueueLimit="5000"
enableKernelOutputCache="true"
enableVersionHeader="true"
requireRootedSaveAsPath="true"
enable="true"
shutdownTimeout="90"
delayNotificationTimeout="5"
waitChangeNotification="0"
maxWaitChangeNotification="0"
enableHeaderChecking="true"
sendCacheControlHeader="true"
apartmentThreading="false" />

By default, this is set to 4096 kilobytes (KB). Simply change this value to increase the size of the files that you can upload to the server. If you want to allow 10 megabyte (MB) files to be uploaded to the server, set the maxRequestLength value to 11264, meaning that the application allows files that are up to 11000 KB to be uploaded to the server.

-::-

Monday, February 05, 2007

How to embed WMP in asp.net pages and how can we redirect the request when the movie ends

You can either user <img> or <object> to embed movies in *.aspx. But to capture the events, you should use the later

Use the below <object tag> to embed WMP in .aspx / html pages
<object id="VIDEO" width="100%" height="100%"
classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"
type="application/x-oleobject">
<param name="URL" value="http://localhost/QaQcTraining/movies/start.wmv" />
<param name="SendPlayStateChangeEvents" value="True" />
<param name="AutoStart" value="True" />
<param name="uiMode" value="none" />
<param name="windowlessVideo" value="True" />
<param name="stretchToFit" value="true" />
</object<

Now, use the below script to capature the events of WMP
<script language=jscript FOR = VIDEO EVENT = playStateChange(NewState) type=text/jscript>
// Test for the player current state, display a message for each.
switch (NewState){
case 1:
//myText.value = "Stopped";
//alert('stoped');
location.href="qform.aspx";
//redirecting to different page after the movie plays
break;

case 2:
//myText.value = "Paused";
//alert('paused');
break;

case 3:
//myText.value = "Playing";
//alert('playing');
break;

// Other cases go here.

default:
//alert('def');
//myText.value = "";
}
</script>

Sunday, January 28, 2007

SQL2000 Enterprise Manager not working after installing SQL2005 version in the same box

When you install both versions together, one after another and try opeining the Enterprise Manager, you may recieve a message as below


snap-in failed to initialize
Name:
CLSID: {00100100-1816-11d0-8eF5-00AA0062c58F}


Resolution
Try reregistering sqlmmc.dll
ie.regsvr32 C:\Program Files\Microsoft SQL Server\80\Tools\Binn\sqlmmc.dll

-:-:-

Wednesday, January 24, 2007

How to implement AJAX in Share Point 2003 ?

There is no straightaway thing to accomplish this. Although Microsoft has released its AJAX toolkit, it is only compatible with .net framework 2.0 while SP2003 is built on .net framework 1.1. To get around this, we have to go for some javascript libraries.
Anthem.net is the best best to achieve. This is basically an open source with rich control functionality built on the top of microsoft's standard web controls. It supports both versions of .net frameworks as well.
To get the ajax functionality for a set of controls in a web page, add anthem panel and embed all standard web controls within it.

Configuration

To get the functionality for a set of controls in the web page, use Anthem Panel control and embed the controls within it. Or else use individual Anthem Controls.

<anthem:panel id="MenuPanel" runat="server" AddCallBacks="true" AutoUpdateAfterCallBack="true"
TextDuringCallBack="Please wait..." width="100%">

In the above configuration, "Please wait..." would be displayed in the control's Text portion while callback happens (TextDuringCallBack). For example, on button click, button text will change to "Please wait.." and remain till callback finishes. AutoUpdateAfterCallBack ensures that controls are refreshed after callback.
While porting the anthem technology to SP server, there are times when the callback updates doesn't happen properly. In that case, in the button click events (triggering events), add MenuPanel.UpdateAfterCallBack=true;

Now develop the webpart and call the webpages as .ascx.

It works great! Enjoy!

Wednesday, August 30, 2006

Opacity property of WinForms is not working

The Opacity property of WinForm will not work for MDI Child forms due to some problems in form paintings. Infact, it is designed ONLY for top level windows.

Read @ http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtskCreatingMDIChildForms.asp

Sunday, August 20, 2006

Integrate SQL Reporting Service 2005 with Sharepoint Portal 2003 with Web Part

Reporting Service rendering web part for share point is available at %\Program Files\Microsoft SQL Server\90\Tools\Reporting Services\SharePoint when SQL Reporting Service 2005 is installed.

Install the above web part in share point with stsadm.exe. It consists of two web parts, Report Explorer and Report Viewer. Report Explorer is basically for listing the reports available in the reporting service in the specified folder (configuration of web part) and Report Viewer web part is for rendering report. Drag both web part in one of the sharepoint pages

Configuration
Enter the report manager url in the "Report Manager URL" property of Report Explorer web part.
Enter the folder name in the "Startpath" property of Report Explorer web part so that it will list only those reports in that folder. (It can remain empty)

In design mode of the page, go to properties of Report Viewer web part and select
Connections - > Get report from -> Report Explorer.

Now, click one of the reports in the Report Explorer web part listing and find the report rendered in the report viewer web part

Zm

Saturday, August 19, 2006

SQL Reporting Service 2005 Express and Business Intelligence Development Studio - How to install and configure ?

SQL Reporting Service 2005 Express is available when you install the SQL Server 2005 Express Edition with Advanced Services SP1 edition. This is frely downloadable at http://msdn.microsoft.com/vstudio/express/sql/download/. Keep the servicing component selected while installing.

To install the Business Intelligence Development Studio, download Microsoft SQL Server 2005 Express Edition Toolkit SP1 from the same URL http://msdn.microsoft.com/vstudio/express/sql/download/

Wednesday, August 16, 2006

Display Mail Inbox, Tasks and Calendar from MS Outlook in Sharepoint Sites with web parts

You can do this in two better ways.

1. Drag "Content Editor Web Part" and paste the following script into the Source Editor

<object classid="clsid:0006F063-0000-0000-C000-000000000046" id="ViewCtlFolder" width="100%" height="400px" codetype= "application/x-oleobject"
codebase="http://activex.microsoft.com/
activex/controls/office/outlctlx.CAB#ver=9,0,0,3203">

<param name="Namespace" value="MAPI">
<param name="Folder" value="Inbox">
<param name="Restriction" value="">
<param name="DeferUpdate" value="0">
</object>



2. Create a generic web part using VS.Net and rewrite the function RenderWebPart like below

protected override void RenderWebPart(HtmlTextWriter output)
{
string str = "--above written script--";
output.Write(str);
}



Note that, to view Calender or Tasks instead of inbox, you can replace the term "Inbox" in the script with corresponding item.

Zm

Monday, August 14, 2006

How to install SQL Server Business Intelligence Development Studio along with SQL 2005 Express and SQL 2005 Reporting Service

SQL Server 2005 Reporting Service is version dependant on SQL Server. If you install SQL 2005 Express, you can only install express edition of SQL Server 2005 Reporting Service (RS).

Business Intelligence Development Studio is the default report designer of SQL Reporting Serivce. It is an addin for VS.Net 2005 with templates for "Report Projects"

How to install the express editions ?
  • Downlaod SQL Server 2005 Express with Advanced Service (this includes the reporting services) and install. While installing keep the item "Reporting Service" checked
  • Download SQL Server 2005 Express Toolkit ( http://www.microsoft.com/downloads/details.aspx?FamilyID=3c856b93-369f-4c6f-9357-c35384179543&DisplayLang=en). The kit includes the business intelligent development studio
  • Now, go to Start - Settings - Control Panel and click Add remove programs
  • Click the "Change" button of MS SQL Server 2005
  • Click the link "To install a new component, click here"
  • Locate the new .exe file of Express Toolkit by clicking the "Browse" button
  • Proceed the installations with "Next" button clicks.

-Zm

Not able to connect Sql Server 2005 Express remotely

"An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) "

By default, when you install Sql Server 2005 Express Edition, it will not allow the applications or clients to connect remotely as like OracleXE. This causes the sytem to throw the above error message.

To enable the remote connection,
  • Go to Start - Programs - Microsoft SQL Server 2005 - Configuration Tools - SQL Server Surface Area Configuration
  • Click the link "Surface Area Configuration for Services and Connections"
  • Now expand the tree SQLEXPRESS - Database Engine - Remote Connections in the "View by Instance" tab
  • Select "Local and remote connections" and "Using both TCP/IP and named pipes" and apply the changes
~Zm

Tuesday, August 08, 2006

Body onLoad() event in content pages - ASP.net 2.0

How we can use the onLoad() event in ASP.Net 2.0 content pages ?

Simple !.
A content page is basicall a page inherited from a MasterPage (.master) in .net framework 2.0. This can be adhieved by either two ways.

1. Javascript function override

Add body onLoad() event in the master page and override the function used in the event in the inherited content pages.

Say,

in master page
<html>
<head>
<script language=" javascript" type=" text/javascript">
function testonload(){ //an empty function
var x = 'empty';
}
</script>
</head>


.
..
...
....
.....



in content page

<asp:content id="Content1" runat="Server" contentplaceholderid="ContentPlaceHolder1">
<script language="javascript" type="text/javascript">
function testonload(prodid, div) {
//client script logic goes here..!!
}
</script>


2. Bind client script to body in code behind

Give an id to the body tag of the masgter page and add runat="server" sot that it is available in the code behind.

Now in content pages, add the following code in the page_load event


HtmlGenericControl body = (HtmlGenericControl)Page.Master.FindControl("bodyMaster");
body.Attributes.Add("onload", "toggle('parameters');");


Keep coding,