I haven't had a chance to fix it, but it doesn't seem to be too difficult to fix.
Tuesday, December 14, 2010
Chrome - User Agent Style Sheet Defaults
All of the sudden, Google Chrome started showing fonts on a different color. Pretty strange, since the website looked fine on Firefox. I looked at the CSS styles and there was some extra styles being loaded from the "User Agent Style Sheet Defaults". There's some good information on this link.
Tuesday, November 23, 2010
Azure Data Market
This is an interesting concept, can't wait to test/consume some of the services on https://datamarket.azure.com/!!
Thursday, November 11, 2010
Nhibernate SQL Server 2008 connection string
Not rocket science, just something that is useful to know.
NHibernate.Driver.SqlClientDriver 10 true NHibernate.Dialect.MsSql2008Dialect true 60 true 1, false 0, yes 'Y', no 'N' NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu
Data Source=localhost;Initial Catalog=LoanApp;User ID=rortiz;Password=test_1983;
Wednesday, November 10, 2010
JavaScript gotcha
If you are using arrays of objects, make sure the last parameter doesn't end with a coma, for example:
test : [
{ myvar: 1},
{ myvar: 2},
{ myvar: 3},
]
This will work fine on Chrome and Firefox, but IE will consider the array to have an extra object . If your code uses the length of the array then it will crash because the last object will be null. How did I figure it out? The hard way...
Saturday, October 30, 2010
Cross domain XMLHttpRequest
It's not possible to use the ArcGIS Server REST API if your parameters have more than 2048 characters and you select HTTP GET. Of course, the REST API UI provides you the option to do an HTTP POST. But how do you do this programmatically?
You use a proxy!! ArcGIS Server provides you one here. More information oh how a proxy works can be found on the Yahoo Developer Network.
I named this post Cross domain XMLHttpRequest because in the context of ExtJS, the ScriptTagProxy doesn't support HTTP POST calls. Therefore, you would use HttpProxy (with a POST method) to access the proxy on the local server. Remember to pass the parameters as properties (instead of concatenating them to the URL).
Friday, October 22, 2010
ArcSDE Views use the incorrect field data type
I've been creating a lot of ArcSDE 9.3 views lately, but it came to my attention that sometimes sdetable creates a field in the view using an incorrect data type. In other words, if the base table has a Double field, the view will show the same field as a Long. What do you do when this happens? It's a nightmare, but one thing you can do is access the table SDE_column_registry and fix the data type there. Just find another field with the target data type and copy the row information.
It would be interesting to see if this happens in ArcSDE 10, which I'll be doing next!
Thursday, October 21, 2010
Concatenating, Minifying and Optimizing JavaScript
Doing this is as important as making sure your code compiles :). I've been reading several articles on how to do this, and they all present different approaches, this is what worked for me:
2) Compress the files: YUI Compressor is the best choice. For it to work correctly I had to use the --charset flag.
1) Concatenate the .js files: I use the copy command; however, it adds some extra characters that later need to be removed for YUI Compressor to work. It does the trick for now though.
2) Compress the files: YUI Compressor is the best choice. For it to work correctly I had to use the --charset flag.
3) Set the content expiration date (using IIS). In my case I set it to expire after 20 days.
4) Finally, enable gzip compression. At first I thought I would need to gzip the files, but it turns out that II5 does this for you. Setting it up is not really straight-forward, check out the section Scenario 1 of this article for IIS 5.0 instructions.
Monday, October 11, 2010
Visual Studio 2010 Extensions
There is a great new feature on Visual Studio 2010 called Extensions (that I just discovered haha). It's pretty cool, specially since there is a gallery from where you can download extensions. My favorite one right now is JSLint. If you are also doing JavaScript development, you'll find it useful as well.
To get started on this new feature, go to Tools and then click on Extension Manager.
Friday, October 8, 2010
Maintainable JavaScript
This is a great screencast on best practices to write maintainable JavaScript code, check it out!
Thursday, October 7, 2010
YUI 3.0 Keeping test cases in different files
In this thread Nicholas Zakas explains how to keep test cases in separate files (instead of using just one file). I tried his solution and it worked... for a few minutes.
YUI 3.0 was supposed to be released one year ago, yet their documentation is not as good as it used to be (like in YUI 2.0). This is one of the reasons I prefer YUI 2.0. It's not as painful as learning Dojo, but it has (what I consider) major changes that are not explained in their documentation. How do they expect us to use their tools?
Friday, October 1, 2010
ExtJS combo doesn't allow empty text
The combo that I was using didn't allow an empty selection after picking a value from the list. Pretty strange, because another combo in the same page was working correctly. It turns out that the data store items need to have an ID greater than 1 because it seems emptyText uses ID=0.
So next time you use emptyText, make sure none of the items in your data store use an ID=0.
So next time you use emptyText, make sure none of the items in your data store use an ID=0.
ASP.NET MVC 2 application doesn't work on IIS 6.0
Nowadays we expect things to just work. I deployed an ASP.NET MVC 2 application on IIS 6.0 and it didn't work at first. I can't remember the exact error, but it was something about the page not being found. After googling the error -and finding a lot of confusing information-, I decided to try http://www.asp.net/. I found the solution on this tutorial.
By the way, what is it with not being able to download ASP.NET MVC 2 from http://www.asp.net/. It's just dumb, being the "official" page to learn ASP.NET MVC, it should have a link to download it.
By the way, what is it with not being able to download ASP.NET MVC 2 from http://www.asp.net/. It's just dumb, being the "official" page to learn ASP.NET MVC, it should have a link to download it.
Thursday, September 30, 2010
JavaScript Unit Testing
YUI Test is probably the best JavaScript testing framework I've found so far. Check it out here.
I have still yet to find a way to call YUI test from a Continuous Integration environment. The default way to call it is by running the website to be tested, but there should be a way to call it remotely and make sure the test passed.
I have still yet to find a way to call YUI test from a Continuous Integration environment. The default way to call it is by running the website to be tested, but there should be a way to call it remotely and make sure the test passed.
Wednesday, September 29, 2010
Sunday, September 12, 2010
Windows 7 crash
The computer has rebooted from a bugcheck. The bugcheck was: 0x00000101 (0x0000000000000019, 0x0000000000000000, 0xfffff880009b1180, 0x0000000000000004). A dump was saved in: C:\Windows\MEMORY.DMP. Report Id: .
ArcMap 10: Definition query not working on a layer with joins
A possible workaround is doing this in a different order: creating a definition query and then setting up the joins. This may work for most scenarios, except when the definition query is dependent on the joined data.
Saturday, September 11, 2010
ArcGIS 10 REST API
Of course, there's always the option of not using joins (and give up good database design). Not an option for me, so I'll check if there's a workaround.
Friday, September 10, 2010
esri.layers.FeatureLayer is not a constructor
Al the API examples show that dojo.addOnLoad should be used but I was using Ext.onReady (another JS API). This was causing the problem because when Ext.onReady was executed the AGS JS API was not loaded. I had to use dojo.addOnLoad to make sure that when I call esri.layers.FeatureLayer it is actually loaded.
Monday, September 6, 2010
JavaScript MVC
This article provides a great start to implement the MVC pattern. I would argue, however, that it can be improved because it doesn't match the definition of MVC from Wikipedia.
One of the problems with the article below is that the View knows about the Controller and the Model, when it should only know about the Model. Although there is at least another problem (hint: the controller doesn't know about the View), it is very easy to fix and you get a perfect implementation of JavaScript MVC.
I am doing this with ExtJS, I'll post some code after I get it to work.
One of the problems with the article below is that the View knows about the Controller and the Model, when it should only know about the Model. Although there is at least another problem (hint: the controller doesn't know about the View), it is very easy to fix and you get a perfect implementation of JavaScript MVC.
I am doing this with ExtJS, I'll post some code after I get it to work.
Saturday, July 24, 2010
Handling SOAP fault exceptions from a WCF service
I was expecting that using catch (Exception ex) would catch the fault (it actually does) and it would be able to retrieve the fault information (not the case). This article showed me how to do it: use catch(FaultException ex) .
Actually, I added catch clauses for both the generic exception and the fault exception. Don't forget the generic exception goes after the fault exception, otherwise the fault exception will never get caught.
Actually, I added catch clauses for both the generic exception and the fault exception. Don't forget the generic exception goes after the fault exception, otherwise the fault exception will never get caught.
Friday, July 23, 2010
ArcGIS Server Context Usage Timeout Interval error
An application that uses ArcObjects was throwing an exception and after some digging, everything was pointing to a problem on ArcGIS Server 9.3.1. The logs showed the error:
"The context has been automatically released because the context usage timeout interval has elapsed"
This KB article indicated that I had to modify the EngineContextTimeout setting in the server.dat file. For some reason, the value in the file was 5, instead of the default 600. It would certainly be nice if the exceptions thrown by ArcGIS Server contained useful information.
"The context has been automatically released because the context usage timeout interval has elapsed"
This KB article indicated that I had to modify the EngineContextTimeout setting in the server.dat file. For some reason, the value in the file was 5, instead of the default 600. It would certainly be nice if the exceptions thrown by ArcGIS Server contained useful information.
Wednesday, July 14, 2010
Access the content page from the paster page
Have you ever wondered how to make the Content page respond to events in the master page? There is a great article here!
Wednesday, July 7, 2010
AJAX Panel vs. Page Methods
A coworker sent this article to me http://encosia.com/2007/07/11/why-aspnet-ajax-updatepanels-are-dangerous/. I have used both technologies (check out ajax.net), and personally, I think Page Methods work great. Just keep in mind that if you use Page Methods, it's better to use Dojo or JQuery to access the DOM.
I have to say that my first thought was that Page Methods were kind of a hack, because they work around the Postback model. Maybe they're just the best of two worlds (client/server side). In my case, I prefer to use Page Methods when a website contains a lot of JavaScript code, and UpdatePanels when server side development is heavy.
,
I have to say that my first thought was that Page Methods were kind of a hack, because they work around the Postback model. Maybe they're just the best of two worlds (client/server side). In my case, I prefer to use Page Methods when a website contains a lot of JavaScript code, and UpdatePanels when server side development is heavy.
,
Thursday, July 1, 2010
Converting an object array into a DataTable using LINQ
This is not possible with the current implementation of LINQ, but it is really easy to extend LINQ to support it. I found how to do it here http://blogs.msdn.com/b/aconrad/archive/2007/09/07/science-project.aspx. The method you need is CopyToDataTable, and the code that supports it is (copied from the link above):
public static class DataSetLinqOperators
{
public static DataTable CopyToDataTable(this IEnumerable source)
{
return new ObjectShredder().Shred(source, null, null);
}
public static DataTable CopyToDataTable(this IEnumerable source,
DataTable table, LoadOption? options)
{
return new ObjectShredder().Shred(source, table, options);
}
}
public class ObjectShredder
{
private FieldInfo[] _fi;
private PropertyInfo[] _pi;
private Dictionary _ordinalMap;
private Type _type;
public ObjectShredder()
{
_type = typeof(T);
_fi = _type.GetFields();
_pi = _type.GetProperties();
_ordinalMap = new Dictionary();
}
public DataTable Shred(IEnumerable source, DataTable table, LoadOption? options)
{
if (typeof(T).IsPrimitive)
{
return ShredPrimitive(source, table, options);
}
if (table == null)
{
table = new DataTable(typeof(T).Name);
}
// now see if need to extend datatable base on the type T + build ordinal map
table = ExtendTable(table, typeof(T));
table.BeginLoadData();
using (IEnumerator e = source.GetEnumerator())
{
while (e.MoveNext())
{
if (options != null)
{
table.LoadDataRow(ShredObject(table, e.Current), (LoadOption)options);
}
else
{
table.LoadDataRow(ShredObject(table, e.Current), true);
}
}
}
table.EndLoadData();
return table;
}
public DataTable ShredPrimitive(IEnumerable source, DataTable table, LoadOption? options)
{
if (table == null)
{
table = new DataTable(typeof(T).Name);
}
if (!table.Columns.Contains("Value"))
{
table.Columns.Add("Value", typeof(T));
}
table.BeginLoadData();
using (IEnumerator e = source.GetEnumerator())
{
Object[] values = new object[table.Columns.Count];
while (e.MoveNext())
{
values[table.Columns["Value"].Ordinal] = e.Current;
if (options != null)
{
table.LoadDataRow(values, (LoadOption)options);
}
else
{
table.LoadDataRow(values, true);
}
}
}
table.EndLoadData();
return table;
}
public DataTable ExtendTable(DataTable table, Type type)
{
// value is type derived from T, may need to extend table.
foreach (FieldInfo f in type.GetFields())
{
if (!_ordinalMap.ContainsKey(f.Name))
{
DataColumn dc = table.Columns.Contains(f.Name) ? table.Columns[f.Name]
: table.Columns.Add(f.Name, f.FieldType);
_ordinalMap.Add(f.Name, dc.Ordinal);
}
}
foreach (PropertyInfo p in type.GetProperties())
{
if (!_ordinalMap.ContainsKey(p.Name))
{
DataColumn dc = table.Columns.Contains(p.Name) ? table.Columns[p.Name]
: table.Columns.Add(p.Name, p.PropertyType);
_ordinalMap.Add(p.Name, dc.Ordinal);
}
}
return table;
}
public object[] ShredObject(DataTable table, T instance)
{
FieldInfo[] fi = _fi;
PropertyInfo[] pi = _pi;
if (instance.GetType() != typeof(T))
{
ExtendTable(table, instance.GetType());
fi = instance.GetType().GetFields();
pi = instance.GetType().GetProperties();
}
Object[] values = new object[table.Columns.Count];
foreach (FieldInfo f in fi)
{
values[_ordinalMap[f.Name]] = f.GetValue(instance);
}
foreach (PropertyInfo p in pi)
{
values[_ordinalMap[p.Name]] = p.GetValue(instance, null);
}
return values;
}
}
Thanks a lot to the author of this code!
public static class DataSetLinqOperators
{
public static DataTable CopyToDataTable(this IEnumerable source)
{
return new ObjectShredder().Shred(source, null, null);
}
public static DataTable CopyToDataTable(this IEnumerable source,
DataTable table, LoadOption? options)
{
return new ObjectShredder().Shred(source, table, options);
}
}
public class ObjectShredder
{
private FieldInfo[] _fi;
private PropertyInfo[] _pi;
private Dictionary
private Type _type;
public ObjectShredder()
{
_type = typeof(T);
_fi = _type.GetFields();
_pi = _type.GetProperties();
_ordinalMap = new Dictionary
}
public DataTable Shred(IEnumerable source, DataTable table, LoadOption? options)
{
if (typeof(T).IsPrimitive)
{
return ShredPrimitive(source, table, options);
}
if (table == null)
{
table = new DataTable(typeof(T).Name);
}
// now see if need to extend datatable base on the type T + build ordinal map
table = ExtendTable(table, typeof(T));
table.BeginLoadData();
using (IEnumerator e = source.GetEnumerator())
{
while (e.MoveNext())
{
if (options != null)
{
table.LoadDataRow(ShredObject(table, e.Current), (LoadOption)options);
}
else
{
table.LoadDataRow(ShredObject(table, e.Current), true);
}
}
}
table.EndLoadData();
return table;
}
public DataTable ShredPrimitive(IEnumerable source, DataTable table, LoadOption? options)
{
if (table == null)
{
table = new DataTable(typeof(T).Name);
}
if (!table.Columns.Contains("Value"))
{
table.Columns.Add("Value", typeof(T));
}
table.BeginLoadData();
using (IEnumerator e = source.GetEnumerator())
{
Object[] values = new object[table.Columns.Count];
while (e.MoveNext())
{
values[table.Columns["Value"].Ordinal] = e.Current;
if (options != null)
{
table.LoadDataRow(values, (LoadOption)options);
}
else
{
table.LoadDataRow(values, true);
}
}
}
table.EndLoadData();
return table;
}
public DataTable ExtendTable(DataTable table, Type type)
{
// value is type derived from T, may need to extend table.
foreach (FieldInfo f in type.GetFields())
{
if (!_ordinalMap.ContainsKey(f.Name))
{
DataColumn dc = table.Columns.Contains(f.Name) ? table.Columns[f.Name]
: table.Columns.Add(f.Name, f.FieldType);
_ordinalMap.Add(f.Name, dc.Ordinal);
}
}
foreach (PropertyInfo p in type.GetProperties())
{
if (!_ordinalMap.ContainsKey(p.Name))
{
DataColumn dc = table.Columns.Contains(p.Name) ? table.Columns[p.Name]
: table.Columns.Add(p.Name, p.PropertyType);
_ordinalMap.Add(p.Name, dc.Ordinal);
}
}
return table;
}
public object[] ShredObject(DataTable table, T instance)
{
FieldInfo[] fi = _fi;
PropertyInfo[] pi = _pi;
if (instance.GetType() != typeof(T))
{
ExtendTable(table, instance.GetType());
fi = instance.GetType().GetFields();
pi = instance.GetType().GetProperties();
}
Object[] values = new object[table.Columns.Count];
foreach (FieldInfo f in fi)
{
values[_ordinalMap[f.Name]] = f.GetValue(instance);
}
foreach (PropertyInfo p in pi)
{
values[_ordinalMap[p.Name]] = p.GetValue(instance, null);
}
return values;
}
}
Thanks a lot to the author of this code!
Saturday, June 26, 2010
WCF Client code is emtpy: Referenced type cannot be used since it does not match imported DataContract. Need to exclude this type from referenced type
Adding a WCF service to a web project ran successfully, but it didn't generate any client classes. I noticed a "silent" warning was generated in Visual Studio 2008 (mentioned in the title of the post), and in order to fix it, I did the following (from this link):
1) Click Advanced in the dialog shown while adding a Service Reference
2) Uncheck "Reuse types from referenced assemblies"
1) Click Advanced in the dialog shown while adding a Service Reference
2) Uncheck "Reuse types from referenced assemblies"
Thursday, June 24, 2010
Expand Infragistics UltraWebListBar programmatically
At first I thought UltraWebListbar1.Groups[0].Expanded would do the trick, but it didn't work. It's possible that Expanded is a read only property. After looking at the documentation, I found that UltraWebListbar1.SelectedGroup was what I needed!
Wednesday, June 23, 2010
Postback doesn't fire when radiobutton is defaulted to checked
This was really strange behavior. I am using an UpdatePanel to trigger a partial postback, and by just setting Checked to true the RadioButton would not trigger a postback. I ended up moving the RadioButtons inside the UpdatePanel, and this fixed the problem.
Is there a logical explanation for this or is this a "feature" (bug)?
Is there a logical explanation for this or is this a "feature" (bug)?
Saturday, June 19, 2010
Making a string bold in ASP.NET
I thought this would require an IFormatProvider, but it's much simpler than that. String.Format will parse HTML tags and display the result:
String.Format("Showing {0} records.", totalItems);
Friday, June 18, 2010
Calculatin Minimum/Maximum Latitude and Longitude
This is actually pretty simple. Just create a new field and then calculate it using this code:
dim pGeom as IGeometry
set pGeom = [shape]
and set the field value to:
Output = pGeom.Envelope.XMin
More info here
Wednesday, June 16, 2010
Invalid postback or callback argument. Event validation is enabled using in configuration...
After doing some research it looks like this problem can happen because of different reasons. In my case I was using some hidden fields and textboxes (asp:HiddenField and asp:TextBox) and also some JavaScript to change the values client-side.
My solution was to put the hidden fields and textboxes inside an UpdatePanel, and generate a partial postback at the same time JavaScript changed the values client-side. Therefore, the postback arguments would be consistent since any JavaScript changes would happen during a partial postback. Not the most clean solution, but it's better than setting EnableEventValidation to false!
My solution was to put the hidden fields and textboxes inside an UpdatePanel, and generate a partial postback at the same time JavaScript changed the values client-side. Therefore, the postback arguments would be consistent since any JavaScript changes would happen during a partial postback. Not the most clean solution, but it's better than setting EnableEventValidation to false!
Monday, June 14, 2010
A control with ID 'myControl' could not be found for the trigger in UpdatePanel 'myUpdatePanel'.
I tried creating the trigger programmatically and assigning the control using FindControl, but it didn't work. This worked for me:
Programmatically adding AsyncPostBackTrigger controls is not supported. Find out the control via findcontrol method, then use the RegisterAsyncPostBackControl(Control) method of the ScriptManager control to programmatically register a postback control, and then call the Update() method of the UpdatePanel when the control posts back.
I found this information here.
Programmatically adding AsyncPostBackTrigger controls is not supported. Find out the control via findcontrol method, then use the RegisterAsyncPostBackControl(Control) method of the ScriptManager control to programmatically register a postback control, and then call the Update() method of the UpdatePanel when the control posts back.
I found this information here.
Sunday, May 23, 2010
MSI project: Unable to build project output group Content Files from MyProject (Active)
If you get this error, it's because the solution project indicated in the error message could not find some files. Enable "Show all files" using the Solution Explorer and check which files are missing (look for a yellow warning icon). More information can be found here.
Monday, April 26, 2010
HttpContext.Current.User.Identity.Name is emtpy
If this happens to you, it's likely you forgot to disable anonymous access for the application.
Wednesday, April 21, 2010
Connecting to an ADAM (Active Directory) instance
There are plenty of articles that will explain how to use AD in .NET. For example, http://channel9.msdn.com/posts/RobertShelton/Searching-Active-Directory-with-NET-Visual-Studio-2005/
The trick (that worked for me) was to use AuthenticationTypes.None when creating a DirectoryEntry.
The trick (that worked for me) was to use AuthenticationTypes.None when creating a DirectoryEntry.
Saturday, April 17, 2010
WCF Services proxy add extra parameters
When calling a WCF service, an output parameter was added to the method. This only happened after adding a second WCF service, and the solution was to add the XmlSerializerFormat attribute to the ServiceContract. Check out this article http://msmvps.com/blogs/windsor/archive/2008/05/17/calling-wcf-services-from-net-1-1.aspx
Friday, April 16, 2010
Debugging custom actions in a Visual Studio 2008 installer
It's simple. Just add the following:
public override void Install(IDictionary stateSaver)
{
Debugger.Break();
...
In order for this to work, I also had to (obviously) build the installer in Debug mode and make sure that Debugger.Break was the first statement in Install(...). This article was really helpful http://harriyott.com/2007/02/debugging-custom-actions-in-visual.aspx
Saturday, April 3, 2010
Hello World
I migrated my blog from my own domain to blogger.com. Transferring the data from my old domain (rortizma.net, which used DNN) was kind of a pain but it's done. Also, blogging using my old domain was too difficult, since I had to do maintenance on the website really often. Using blogger.com should be easier since Google takes care of the back-end.
Subscribe to:
Posts (Atom)