Tuesday, February 9, 2010

Grid CausedCallback and IsCallback values are incorrect

I am using a ComponentArt grid on one of the ASP.Net pages. In the Page_Load() I have the code to load the grid. The code looks something like this...

protected void Page_Load(object sender, System.EventArgs e)
  if(Page.IsPostBack == false)

This works well, the buildGrid() is called only when the page is loaded for the first time and when a postback occurs the function is skiiped.

However my grid a paging enabled and grid runs at server side (runat="server"). This mean grid would postback everytime you naviage from page to page. So adding another check as follows...

protected void Page_Load(object sender, System.EventArgs e)
  if(Page.IsPostBack == false &&
   Grid1.CausedCallabck ==false )

This means buildGrid() is skipped when when Grid1 caused the callback (e.g. navigating from page to page within the grid).

But here is the problem. The Grid1.CausedCallback is false when you load the page for the first time and changes to true when you change pages on the grid but remain true there after. Even if you navigate away from the page that contains the grid to something totally different and come back to this page Grid1.CausedCallback remains true. This can cause many problem based on the implementation you have.

I am not sure what the problem is, it could be a bug in the component itself. I did spend sometime to figure it out but with no luck. So I decided to use a work around.

Work around:

The Request object has a property called UrlReferrer. This basically tells us from which page the request is coming to the current page. This mean when ever the UrlReferrer is otherthan current page(page with the grid) we know the user is landing on current page for the first time. So the final code looks something like this.

protected void Page_Load(object sender, System.EventArgs e)
  string url = Request.UrlReferrer.ToString();
  if(Page.IsPostBack == false &&
    url.ToLower().Contains("currentpagename.aspx")==false )

Monday, August 31, 2009

Unable to connect to internet in Virtual PC

I ran into this issue recently. I installed Microsoft Virtual PC on my host machine running Windows XP. Created a new Virtual PC and installed Windows Service Pack3 on it. By default the Networking adapter is set to the physical network adapter of the host machine. Everything looked good so I fired up my new VPC, opened the browser and tried accessing some site. Problem!

So I decided to change the Network work adapter of the VPC to Shared Netowrking (NAT). In this mode VPC would share the network connection available on the host machine instead connecting directly to the network adapter on the host machine. But still no luck.

In both cases I could ping the host machine from the Virtual PC. Which meant there is network connection on VPC but something is preventing internet connections. The first thing to look at in such scenario would be Firewall. So I decided to quickly check if disabling the firewall on the VPC would do the trick. That didn't make any difference. Note disabling firewall is not a good idea. I was just using to narrow the issue down. So I turned the firewall back on on the VPC.

The next step was to look at the Firewall on the host machine. Instead of disabling the firewall this time I looked at the Exception tab of the firewall configuration window. This tab basically lists the applications that have previlages to pass through the firewall. I decided to add Microsoft Virtual PC into the list. After adding it to the list, clicked on the "Add Port" button and added port 80. That's it!!! The problem is fixed. Hope this helps some one. Drop a line if this worked or you have any comments.

Wednesday, February 4, 2009

File not found when recreating a sub site in SharePoint

For whatever reason I had to delete a sub site that I create under the default team site in SharePoint. The deleting is easy. But when you try to recreate the same site again you would get

File not found followed by a stack trace

Just restarting the IIS should fix the problem

Tuesday, February 3, 2009

File Not Found when creating a new site in SharePoint

I ran into this problem when creating a new sub site (Sites and Workspaces) under the default team site that gets created when you install SharePoint Services. I would get File Not Found every time I tried creating a new site under the main site. Though I found lot of information on the internet on resolving the issue, none of them worked for me.

The solution is very simple. Under STN Team Site > Site Settings > Sites and Workspaces click on "Site Creating Permission" button. Select the "Design" permission level and click OK. That's it, now you should be able to create any number of new sites.

The error File Not Found is miss leading when the issue is related to permissions.

Thursday, July 3, 2008

OracleXETNSListener colud not be started

I have been using Oracle XE for months and suddenly one day I could not connect to the database. I found that the listener was not running and I attempted stop and then start the listener through the menu options(Programs->Oracle 10g Express Edition->Start Database,StopDatabase). The listener did not start.

I found many forums that talked about the same issue. Different solutions worked for different people. I tried all the solutions that were recommended but none of them really fixed my problem. One of the forum recommended reinstalling OracleXE. (Note: reinstalling will wipe out any database that you already have on XE). There are instuction to get around this problem, see Oracle XE Installation instructions for more info. So I decided to reinstall Oracle XE but it is not as straight as one might think. Here are the steps that I followed

1. login to the machine as administrator (this seems to be very important). You may be thinking your domain account as local administrator rights. That doesn't really matter. Oracle requires you to login as adminstrator of the machine.

2. Run Oracle XE setup exe. You will be prompted to either Repair or Remove. Choose Remove.

3. Complete the remove process.

4. Open Environment variables (My Computer->Properties->Advanced->Environment Variables)

5. Remove ORACLE_HOME and ORACLE_SID system variables (This is very important. My previous attempt without this step did not fix my problem)

6. Reboot the machine. (one more important step)

7. Log in as administrator

8. Install Oracle XE

That's it! You should be able to open Oracle Home.

Drop couple of lines if this worked for you.

Thursday, June 5, 2008

Cannot open Oracle XE database home page

Sometimes when you install Oracle XE on your desktop and try to access the home page through the internet explorer, it may not open and IE displays an error page. There are two things that seem to fix the problem

1. When you install Oracle XE on your desktop, login as local administrator instead of your company domain account. The install instruction says as long your domain account has administration rights on the computer it will work. But that's not the case when I installed XE. So I uninstalled oracle xe, logged off as domain user, logged back-in as local adminstrator.

The username for local administrator is usually "administrator." If you don't remember the password, you can just reset it by logging in as domain user.

If you are trying to open the database home from a different machine than the machine running Oracle XE, you may want to do the following

1. Make sure remote connection is allowed to this database. For that you will have to goto the machine where the database is running and change the setting. The option is available under administrative task.

2. Also make sure the firewall is not enable on machine where the database is running. If the firewall is enabled, it may block the calls to communicate with the database. Chaning the fire wall settings is very easy. Select the LAN connection properties. Click advanced tab and then click settings. Here you can enable\disable firewall.

Thursday, November 1, 2007

Automation Error System cannot find the file specified

You might run it to this problem when you are trying to load a COM exposed .net component from a COM application such as VB. The problem is that the COM is not able to find your component in the registry. Here are some of the resolutions you can try

- Enable Register for COM interop in the project properties window

This use to be enough in .Net 1.1 /VS 2003 to get the component registered. But in .Net 2.0/VS 2005, Microsoft introduced another way to specify the COM visibility. That is by introducing a new attribute [assembly: ComVisible(true)]. Add this attribute to your AssemblyInfo.cs file and recompile the project.

If you are still having the problem, try registering the component explicitly using

regasm c:\abc\abc.dll /tlb

sometimes the /tlb option does the trick.

If this doesn't fix the problem check the version number of the component on which your component depends on. If the components, on which your component depends, are singed with specific key and are of specific version, then your component also need to be signed with the same key and versioned the same. Otherwise you will get the same automation error when loading from the component from a COM client. In .Net2.0 you update the AssemblyInfo.cs to update the version number and sign the component


[assembly: AssemblyVersion("x.x.x.x")]
[assembly: AssemblyFileVersion("x.x.x.x")]

[assembly: AssemblyKeyFile(@"your_key.snk")]

Hope this helps.