If you want to keep the view state server-side or in some other place on the rendered page.
You might, for instance, determine that the wire cost exceeds the server-side memory cost and therefore want to keep View State on the server.
Override these two methods :
Saves any view-state information for the page.
Override this method if you want to save the Page view state in anything other than a hidden field. If you choose to do so, you must also override the Page.LoadPageStateFromPersistenceMedium method.
protected virtual void SavePageStateToPersistenceMedium(object viewState);
Loads any saved view-state information to the Page object. Override this method if you want to load the Page view-state information in anything other than a hidden field.
If you want to specify something other than hidden fields to save view state when using this method, you must also override the SaveStateToPersistenceMedium method.
protected virtual object LoadPageStateFromPersistenceMedium();
Tuesday, August 09, 2005
Thursday, December 02, 2004
Joining on objectSID or using objectSID in a WHERE Clause
This one drove me crazy for the better part of a day.
When SQL Server shows you an objectSID it looks something like this:
0x010500000000000515000000317B347F75771D5BB254B44007080000
If you take that string and type something like:
SELECT * FROM viewADEmployees WHERE objectSID = 0x010500000000000515000000317B347F75771D5BB254B44007080000
It works just fine.
But if you take that string and stuff it in a VARCHAR (or any other type you think might be appropriate) you get an empty result set.
So I thought, duh, I need to cast it to the same type as objectSID. It only took a little while to figure out that objectSID is of type VARBINARY. It turns out, however, that simply casting the string to VARBINARY does NOT work! In fact I could not find any CAST or CONVERT that did the trick. I performed more casts than the entire fishing population on opening day of trout season.
Google was of no help either. I was on my own on this one.
I finally stepped back reasoned it out:
1. objectSID is VARBINARY
2. I need to convert my comparison value to VARBINARY
3. I should create a user function that takes a string representation of a series of hex byte values
4. each two-character pair of hex digits reprsents a single binary byte
5. I need to build up a VARBINARY value by successively converting the pairs to integers and then adding them to my VARBINARY return value
This is my resulting function which took a suprisingly short period of time to conceive, write and debug :
CREATE FUNCTION dbo.fncFormatSID (@vchFromSID VARCHAR(300))
RETURNS VARBINARY(85)
AS
BEGIN
DECLARE @binOut VARBINARY(85);
DECLARE @intLen INT;
DECLARE @intIndex INT;
DECLARE @intLow INT;
DECLARE @intHigh INT;
DECLARE @vchLow VARCHAR(1);
DECLARE @vchHigh VARCHAR(1);
SELECT @intLen = LEN(@vchFromSID)
SELECT @intIndex = 2
WHILE (@intIndex < @intLen)
BEGIN
SELECT @vchHigh = SUBSTRING(@vchFromSID, @intIndex, 1)
SELECT @vchLow = SUBSTRING(@vchFromSID, @intIndex + 1, 1)
IF(@vchLow >= '0' AND @vchLow <= '9')
BEGIN
SELECT @intLow = ASCII(@vchLow) - ASCII("0");
END
IF(@vchHigh >= '0' AND @vchHigh <= '9')
BEGIN
SELECT @intHigh = ASCII(@vchHigh) - ASCII("0");
END
IF(@vchLow >= 'A' AND @vchLow <= 'F')
BEGIN
SELECT @intLow = ASCII(@vchLow) - ASCII("A") + 10;
END
IF(@vchHigh >= 'A' AND @vchHigh <= 'F')
BEGIN
SELECT @intHigh = ASCII(@vchHigh) - ASCII("A") + 10;
END
IF @binOut IS NULL
BEGIN
SELECT @binOut = CONVERT(VARBINARY(1), (@intHigh * 16) + @intLow) ;
END
ELSE BEGIN
SELECT @binOut = @binOut + CONVERT(VARBINARY(1), (@intHigh * 16) + @intLow) ;
END
SELECT @intIndex = @intIndex + 3
END /* While */
RETURN(@binOut);
END
When SQL Server shows you an objectSID it looks something like this:
0x010500000000000515000000317B347F75771D5BB254B44007080000
If you take that string and type something like:
SELECT * FROM viewADEmployees WHERE objectSID = 0x010500000000000515000000317B347F75771D5BB254B44007080000
It works just fine.
But if you take that string and stuff it in a VARCHAR (or any other type you think might be appropriate) you get an empty result set.
So I thought, duh, I need to cast it to the same type as objectSID. It only took a little while to figure out that objectSID is of type VARBINARY. It turns out, however, that simply casting the string to VARBINARY does NOT work! In fact I could not find any CAST or CONVERT that did the trick. I performed more casts than the entire fishing population on opening day of trout season.
Google was of no help either. I was on my own on this one.
I finally stepped back reasoned it out:
1. objectSID is VARBINARY
2. I need to convert my comparison value to VARBINARY
3. I should create a user function that takes a string representation of a series of hex byte values
4. each two-character pair of hex digits reprsents a single binary byte
5. I need to build up a VARBINARY value by successively converting the pairs to integers and then adding them to my VARBINARY return value
This is my resulting function which took a suprisingly short period of time to conceive, write and debug :
CREATE FUNCTION dbo.fncFormatSID (@vchFromSID VARCHAR(300))
RETURNS VARBINARY(85)
AS
BEGIN
DECLARE @binOut VARBINARY(85);
DECLARE @intLen INT;
DECLARE @intIndex INT;
DECLARE @intLow INT;
DECLARE @intHigh INT;
DECLARE @vchLow VARCHAR(1);
DECLARE @vchHigh VARCHAR(1);
SELECT @intLen = LEN(@vchFromSID)
SELECT @intIndex = 2
WHILE (@intIndex < @intLen)
BEGIN
SELECT @vchHigh = SUBSTRING(@vchFromSID, @intIndex, 1)
SELECT @vchLow = SUBSTRING(@vchFromSID, @intIndex + 1, 1)
IF(@vchLow >= '0' AND @vchLow <= '9')
BEGIN
SELECT @intLow = ASCII(@vchLow) - ASCII("0");
END
IF(@vchHigh >= '0' AND @vchHigh <= '9')
BEGIN
SELECT @intHigh = ASCII(@vchHigh) - ASCII("0");
END
IF(@vchLow >= 'A' AND @vchLow <= 'F')
BEGIN
SELECT @intLow = ASCII(@vchLow) - ASCII("A") + 10;
END
IF(@vchHigh >= 'A' AND @vchHigh <= 'F')
BEGIN
SELECT @intHigh = ASCII(@vchHigh) - ASCII("A") + 10;
END
IF @binOut IS NULL
BEGIN
SELECT @binOut = CONVERT(VARBINARY(1), (@intHigh * 16) + @intLow) ;
END
ELSE BEGIN
SELECT @binOut = @binOut + CONVERT(VARBINARY(1), (@intHigh * 16) + @intLow) ;
END
SELECT @intIndex = @intIndex + 3
END /* While */
RETURN(@binOut);
END
Accessing Active Directory From SQL Server
Figured out how to query active directory from SQL Server. Its pretty well documented but the first step is to create what is know as a 'Linked Server'. This involves executing one line of code in Query Analyzer:
sp_addlinkedserver 'ADSI', 'Active Directory Service Interfaces', 'ADSDSOObject', 'adsdatasource'
Then you can execute stuff like this:
SELECT * from openquery(ADSI, 'SELECT cn,objectsid FROM ''LDAP://atlas/CN=Users,DC=doublestarinc,DC=com''')
I'm not sure if its possible to perform a join directly with this. To save time I created a view using something similar to the above SELELCT statement. Then using that view we can all join to our heart's content.
sp_addlinkedserver 'ADSI', 'Active Directory Service Interfaces', 'ADSDSOObject', 'adsdatasource'
Then you can execute stuff like this:
SELECT * from openquery(ADSI, 'SELECT cn,objectsid FROM ''LDAP://atlas/CN=Users,DC=doublestarinc,DC=com''')
I'm not sure if its possible to perform a join directly with this. To save time I created a view using something similar to the above SELELCT statement. Then using that view we can all join to our heart's content.
Friday, November 05, 2004
Passed 70-316 Today !
Scored a 920 !
Didn't think I did better than the 70-315 test but somehow I did.
Now on to 70-320.
Didn't think I did better than the 70-315 test but somehow I did.
Now on to 70-320.
Tuesday, September 28, 2004
Whacky, Nutty Keyboard Antics
My keyboard layout got whacked out for Office products only.
a would print q, comma would print : stuff like that.
Solution:
All Programs -> Microsoft Office -> Microsoft Office Tools -> Microsoft Office 2003 Language Tools.
All Programs -> Microsoft Office Tools -> Microsoft Office XP Language Tools.
In both locations found the French to be the Enabled and Active Language.
Deleted it from the the Active Lists.
Viola!
a would print q, comma would print : stuff like that.
Solution:
All Programs -> Microsoft Office -> Microsoft Office Tools -> Microsoft Office 2003 Language Tools.
All Programs -> Microsoft Office Tools -> Microsoft Office XP Language Tools.
In both locations found the French to be the Enabled and Active Language.
Deleted it from the the Active Lists.
Viola!
Wednesday, September 15, 2004
Tools I Used Today
Made my first professional forray into VBA / Access Front end development.
Yuck!
Did a good job though.
Yuck!
Did a good job though.
Monday, August 02, 2004
Tuesday, July 20, 2004
Tools I've used recently
Wrote my first Fortran Program!
My nephew is taking a course in it and was having trouble.
I found an online Fortran 90 reference and quickly had the program working.
I even pulled a Unix command line tool out of my rear-end to kill a couple of processes (ps).
When done, he called me a 'Programming God'.
Boy, am I now all puffed up.
Successfully debugged a VB / Windows Scripting Host app.
cscript.exe
My nephew is taking a course in it and was having trouble.
I found an online Fortran 90 reference and quickly had the program working.
I even pulled a Unix command line tool out of my rear-end to kill a couple of processes (ps).
When done, he called me a 'Programming God'.
Boy, am I now all puffed up.
Successfully debugged a VB / Windows Scripting Host app.
cscript.exe
How to Debug Classic ASP in VS.NET
Make the following configuration mods:
In VS.NET:
project - properties
configuration properties
debugging
- enable ASP debugging
- enable ASP.NET debugging
In the IIS snap-in:
default website - properties
home directory tab
configuration
app debugging
- enable ASP server-side script debugging
Add IIS process account to Debugger Users group:
In Computer Management snap-in:
System Tools
Local Users and Groups
Groups
Debugger Users - properties
Add user IWAM_machine-name (the "Launch IIS process account")
In VS.NET:
project - properties
configuration properties
debugging
- enable ASP debugging
- enable ASP.NET debugging
In the IIS snap-in:
default website - properties
home directory tab
configuration
app debugging
- enable ASP server-side script debugging
Add IIS process account to Debugger Users group:
In Computer Management snap-in:
System Tools
Local Users and Groups
Groups
Debugger Users - properties
Add user IWAM_machine-name (the "Launch IIS process account")
Wednesday, July 07, 2004
Making a Web Apps Browser Window Maximized at Start Up
Finally figured out (first time I tried) how to make the browser maximize upon application start:
in html HEAD add this script/function block:
script lang="javascript"
function doOnLoad()
{
window.resizeTo(window.screen.availWidth, window.screen.availHeight);
window.moveTo(0, 0);
}
/script
Then in the BODY tag add this:
onload="javascript:doOnLoad()"
poof! works.
in html HEAD add this script/function block:
script lang="javascript"
function doOnLoad()
{
window.resizeTo(window.screen.availWidth, window.screen.availHeight);
window.moveTo(0, 0);
}
/script
Then in the BODY tag add this:
onload="javascript:doOnLoad()"
poof! works.
Tuesday, July 06, 2004
Hooking up Client Side Jave Script with MyButton.Attributes.Add()
The Session[MadeChangesIndex] stores a boolean indicating if any changes have been made to the lists/data grids.
In the Page_Load() Handler added:
if((bool)Session[MadeChangesIndex])
Cancel_PB.Attributes.Add("onClick", "return(HandleCancel(true));");
else
Cancel_PB.Attributes.Add("onClick", "return(HandleCancel(false));");
In the HEAD tag of the HTML added:
function HandleCancel(ListChanged)
{
if(ListChanged)
return(confirm("Are you sure you want to Discard ALL of your Edits? This includes any changes to the Work Item, Participant and Client Lists."));
else
return(confirm("Are you sure you want to Discard ALL of your Edits?"));
}
Works Great!
What I'd like to do is figure out how to walk the elements of the form and determine if any of the controls have been modified and exit without confirmation if nothing has changed.
In the Page_Load() Handler added:
if((bool)Session[MadeChangesIndex])
Cancel_PB.Attributes.Add("onClick", "return(HandleCancel(true));");
else
Cancel_PB.Attributes.Add("onClick", "return(HandleCancel(false));");
In the HEAD tag of the HTML added:
function HandleCancel(ListChanged)
{
if(ListChanged)
return(confirm("Are you sure you want to Discard ALL of your Edits? This includes any changes to the Work Item, Participant and Client Lists."));
else
return(confirm("Are you sure you want to Discard ALL of your Edits?"));
}
Works Great!
What I'd like to do is figure out how to walk the elements of the form and determine if any of the controls have been modified and exit without confirmation if nothing has changed.
Subscribe to:
Posts (Atom)
C# Sucks!
JK!! Seriously, though, somewhere around C#-3 we should have inculcated ourselves with the question: "Does 'CAN' == 'SHOULD...
-
Have now wasted several hours downloading and evaluating SQL Test Data Generators. The only one that actually 'worked' doesn't ...
-
Ran into a small head scratcher today. I'm getting ready for a demo which will have to run without an Oracle DB connection. To test ...