Tuesday, July 28, 2009

Setting Default button in ASP

The other day I saw a posting on a forum about setting Default button for a web form. Till that day I had not tried that thing out (I just vaguely remembered that there's something like a DefaultButton property). So when I created a simple form with a text box, button and a gridview wrapped in an Update Panel, I just couldn't locate the property anywhere (no property in asp:Button tag, no this.DefaultButton). Then I read that to achieve the default button property you need to do:
ClientScript.RegisterHiddenField("__EVENTTARGET", submitButton.UniqueID);
Once the code was in place and I hit the "enter" key and lo and behold another cryptic error
Microsoft JScript runtime error: 'this._postBackSettings.async' is null or not an object
Then I read on another blog that you need to put a panel around and set the DefaultButton property value. Though this was not the response I was looking for but I got an idea as to where to look for the DefaultButton thing. So, I removed my ClientScript.RegisterHiddenField code and set the
defaultbutton="submitButton"
in form tag. And that was it!

Thursday, July 16, 2009

Sys.WebForms.PageRequestManager error

While creating a new .Net 2.0 project I encountered something that had never happened to me when creating other ASP.Net web applications.

I had this new ASP.Net web application and I put in a script manager in the Master Page and an update panel in one of the content pages. When running this simple setup I got an error that had never happened before
Sys.WebForms.PageRequestManager._initialize Microsoft JScript runtime error: 'Sys' is undefined
This left me a bit confused but a bit of search on the web and I realized that there were some key values missing from the web.config.

Other projects that I had created were taken as AJAX enabled template projects and hence never posed any issue. The solution was to create a new ASP.Net AJAX enabled web application and then copy-paste the relevant sections from the new project in your web.config.

SSIS: Changing connection string in Data flow dynamically

Recently I was developing an SSIS package where I had to source data values from Oracle and SQL Server. The SSIS package had multiple For..Loop containers to mimic threading structure in SSIS. Since, at design time I couldn't identify which SQL query (the source) would execute in which For..Loop container, I decided to source the connection string from a table in my SQL Server and then assign it to the OLEDB source at runtime.

For package validation purposes, I had an Oracle connection assigned to the OLEDB source at design time.

Everything works fine till here. But when I ran the package, I found that it will throw an error
Error: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80040E14. An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80040E14 Description: "Statement(s) could not be prepared.". An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80040E14 Description: "Invalid object name 'MyTable'".

And
[DTS.Pipeline] Error: "component "Alert values from Oracle" (585)" failed validation and returned validation status "VS_ISBROKEN".
After much turmoil I found that for some weird reason the "Initial Catalog" value assigned in the connection string for SQL Server doesn't work as expected. And since the schema assigned to the package user would connect to Master database it couldn't locate the table mentioned.

Solution: Use the absolute table path in the FROM clause like
select column1 from dbname.schema.mytable
And that did the trick.