Wednesday, October 14, 2009

Get the result of dynamic SQL into a variable?

I needed this kind of functionality for something at work.

What you'll have to do is use dynamic SQL and sp_executeSQL. Try the following example:

CREATE PROCEDURE dbo.countTables
@dbname SYSNAME
AS
BEGIN
DECLARE @i INT, @sql NVARCHAR(512)

SET @sql = N'SELECT @i = COUNT(*) FROM '
+ @dbname + '.INFORMATION_SCHEMA.TABLES'

EXEC sp_executesql
@query = @sql,
@params = N'@i INT OUTPUT',
@i = @i OUTPUT

PRINT @i
END
GO

Some of the principles work for me - haven't gotten it to do what I need, but its a great help! Can work my way around my problem now.

Read the full article here.

Friday, September 18, 2009

DeepZoom overlaying

In a previous Blog entry I mentioned that I had SUCH a hassle to overlay a subimage with something else to make it look "seemless".

Well - I found a blog where they explained how they did it for a msi as a whole. So I will try and use it to fit my own needs - but here is that site. NJoy!

Wednesday, August 19, 2009

Uploading Silverlight Apps to Live

I uploaded a test app previously to live for testing purposes and couldn't remeber HOW today :)

So here are the steps:
> Add a file "manifest.xml" to the directory your XAP file is in... it should look something like this:

2.0
Test.xap


> Zip up the manifest.xml and *.xap and any other data directory you might have (eg. TestFiles)
> Log into the http://silverlight.live.com site.
> Go to Manager Applications
> Upload the Zip and follow the instructions
> Copy and paste the html you need into the web / blog u need to
> Done

Friday, July 17, 2009

ZOrder (ZIndex) in Silverlight 2

The Z-Order in Silverlight is (according to a blog I read) a bit messy.

So - what you can do to set the Z-Order is to change the Canvas.ZIndexProperty. This still doesn't work though, so one guy suggests to change the Opacity directly after changing this property. In my case the original Opacity was eg. 1... then it will look like this.

(I tested it and it works for me)

iCanvas.SetValue(Canvas.ZIndexProperty, 10);
iCanvas.Opacity = 0.9;
iCanvas.Opacity = 1.0;

Wednesday, July 8, 2009

Trying to make Delegates more "clear"

I often have to go back to see how to use delegates. I don't know WHY, but I keep forgetting the fundamentals of if...

Well - basically in Class B, you will create a Delegate. Within this class u will raise an event through the delegate. This event will then have to be handled in Class A (which uses Class B)..

CLASS B

CLASS A

Tuesday, July 7, 2009

Manipulating (scale & transform) an object in Silverlight

TransformGroup transformGroup = new TransformGroup();

RotateTransform rotateTransform = new RotateTransform();
rotateTransform.Angle = 180;
transformGroup.Children.Add(rotateTransform);

ScaleTransform scaleTransform = new ScaleTransform();
scaleTransform.ScaleX = .50;
scaleTransform.ScaleY = .50;
transformGroup.Children.Add(scaleTransform);

polygon.RenderTransform = transformGroup;

A fuller example here.

Friday, June 12, 2009

Testing my deepzoom page

I am playing around with some deepzoom stuff...
This might show nothing... just trying to make it work :)

Tuesday, March 17, 2009

Persist data from a user control back to the page

This is maybe something very specific to my scenario, but I needed to persist data from a user control back to the page holding this control.

I used the following.

In the Page Class: (MyPage)
------------------
I declared the class as such

class MyPage : BasePage, MyFilter.IFilterPersist

I added the following methods

public string GetLastSearchSupplier(string controlId)
{
if (ViewState[controlId] == null) ViewState[controlId] = "-12";
return (string)ViewState[controlId];
}
public void SetLastSearchSupplier(string controlId, string value)
{
ViewState[controlId] = value;
}

In the User Control: (MyFilter)
--------------------

I declared an Interface

public interface IFilterPersist
{
string GetLastSearchSupplier(string controlId);
void SetLastSearchSupplier(string controlId, string value);
}

I declared an instance of the filter

IFilterPersist ownerI;

In the constructor I instantiated the filter

this.ownerI = parentPage as IFilterPersist;

Where I wanted to Get or Set this value to persist it to the containing page I did this

call GetLastSearch... / SetLastSearch...(userControl.ID, "sdsad");

Tuesday, January 27, 2009

Setting focus after a postback

I kept loosing focus after the Anthem.net postback.

The issue was that I needed to remain focus on a textbox a user selected even after the previous textbox made a postback in order to do eg. textchanged....

I found THIS piece of code.

Including Javascript block from within C# code

I needed to write some Javascript from within C#

The problem is that I can't add it directly to the file since we use classes which forms our form. So I stumbled across this piece of code which will help!

Default RE: How to implement ClientScript.RegisterClientScriptInclude
Howdy,

1. declaratively (aspx page code)


or programmatically in master page load / init/ prerender / any event
handlers:
Page.ClientScript.RegisterClientScriptInclude("my" ,
ResolveClientUrl("~/scripts/timer.js"));

2. i reckon instead of ClientScript.RegisterClientScriptSource you meant
ClientScript.RegisterClientScriptBlock (or if i got you wrong, do you use
store javascripts in a resource file?)
If i got you right, try this:

protected void Page_Load(object sender, EventArgs e)
{
RegisterMessageScript("Hello World!");
}

private void RegisterMessageScript(string message)
{
System.Text.StringBuilder script =
new System.Text.StringBuilder();

script.Append("\n");

Type type = this.GetType();

if(!ClientScript.IsClientScriptBlockRegistered(typ e, "messageScript"))
ClientScript.RegisterClientScriptBlock(type, "messageScript",
script.ToString());

}

hope this helps

Milosz

You can view it online here.