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"

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)?

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!

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.