Sending data from javascript to a .Net object

Recently I came across an issue where I had checkboxes outputted via XSLT (which only outputs HTML) but needed to have the values of the selected checkboxes sent to a C# object.  After banging my head against the wall and trying various schemes I remembered that JavaScript can be used to perform a postback.  Now if there was only some way to pass data when performing the postback.  Turns out there is.

In JavaScript you can use the call  “__doPostBack(variablename, value);” to perform the postback and send the variable along with it.  For instance,



performs a postback, sending the variable “ShareBlog” with the value “Rocks”.

In your code (C# in my case) you can read in this variable and use it as you will



if (Page.IsPostBack)


   string eventTarget = Page.Request[“__EVENTTARGET”];  

   string eventArgument = Page.Request[“__EVENTARGUMENT”];  

   if (eventTarget != String.Empty && eventTarget == “ShareBlog”)  

   {     //do what you will with the eventArgument   }



Note that you would replace “Shareblog” in the second if statement with the name of your variable you used in the “__doPostBack” statement.

No mapping between account names and security ids was done

I just created a new SQL Server 2008 server with Hyper-V and was in the process of setting up my VMs complete with AD.   When I got to the point of adding a SQL Server 2008 to the mix I recieved the above error when I was trying to add the domain users as the service owners.   Another odd thing was when I tried to add a domain account to a local security group it would say the user was added however I would not see the account show up in the group.

After rebuilding my AD and SQL 2008 VMs a few times I realized that when I ran SYSPREP on my baseline image I did not check the box called “Generalize” which removes all unique information like the SID.   Hence, it appeared that I was running 2 machines with the same SID.   After rebuilding my baseline image and running SYSPREP the correct way everything worked correctly.