Thursday 4 August 2011

Quickest Way to design a List Template

Overview
Any type of deployment on the SharePoint Farm must be done via Features. These features would be contained within a WSP package which would be deployed using stsadm –o addsolution command.
The main gist is to facilitate not only the adding/retraction of these features but also the automation of the entire process by using batch files and window schedulers.


ListTemplate

ListTemplate is simply a schema of a SharePoint List. It is based on XML. It is considered to be the natural way of adding a new type of List.
Its formation includes declaring content types, views, fields, and forms.

Quickest way

There are many ways of creating a ListTemplate. The most easiest way, I believe, is to create the List with the columns that you want using the SharePoint UI[1] (i.e Site Settings  View All Contents  Create). Save it as a List template. Download the stp file, change it to a cab file, export its content and then copy and past the part of that file and paste it into your schema.xml
The schema.xml would be part of your solution it should be located at the same position then in Fig 1. Note that the name of the folder (Vydio) may be different based on the name attribute of your feature.xml

[1] http://office.microsoft.com/en-au/windows-sharepoint-services-help/create-a-list-HA010099248.aspx#BM1


Fig 1. Note that the aspx file may not be needed









Feature.xml

< Feature Id="09e1e9f5-79ee-4eb7-8cc1-094a2506cd8a"
Title="VydioList"
Description="This is the List Template for the Vydeo SharePoint List (Video Conference)"
Version="12.0.0.0"
Hidden="FALSE"
Scope="Web"
DefaultResourceFile="core"
ReceiverAssembly="Macmillan.Greenroom.ListTemplate, Version=1.0.0.0, Culture=neutral, PublicKeyToken=4708d659fa6e9b7f"
ReceiverClass="Macmillan.Greenroom.ListTemplate.VydioFeatureReceiver"
xmlns="http://schemas.microsoft.com/sharepoint/">
< ElementManifests>










Notice: the difference between ElementManifest and ElementFile, also note the scope which is Web. This very important if you which to be able to used the event receiver correctly for that particular scenario.



ListTemplate.xml

< Elements Id="d3774b95-c579-44cc-b4e6-2fc23bb708ac" xmlns="http://schemas.microsoft.com/sharepoint/">
< ListTemplate Name="Vydio"
DisplayName="Vydio"
Description="Create a Vydio List"
SecurityBits="11"
BaseType="0"
Type="100"
FeatureId="09e1e9f5-79ee-4eb7-8cc1-094a2506cd8a"
OnQuickLaunch="FALSE"
Image="/_layouts/images/itgen.gif"/>


Notice the name would determine the name of the folder holding the schema.xml and other files (e.g. aspx)



ListInstance.xml

It is in charge of creating instance of the list template.


< Elements Id="62E9CB07-AAF1-4fa5-A89E-141A954A8B75" xmlns="http://schemas.microsoft.com/sharepoint/">
< ListInstance
FeatureId="09e1e9f5-79ee-4eb7-8cc1-094a2506cd8a"
Title="Vydio 1"
Description="Vydio 1 (Video Confenrencing)"
OnQuickLaunch="FALSE"
Id="1036"
TemplateType="100"
Url="Lists/Vydio 1">

< ListInstance
FeatureId="09e1e9f5-79ee-4eb7-8cc1-094a2506cd8a"
Title="Vydio 2"
Description="Vydio 2 (Video Confenrencing)"
OnQuickLaunch="FALSE"
Id="1037"
TemplateType="100"
Url="Lists/Vydio 2">

< ListInstance
FeatureId="09e1e9f5-79ee-4eb7-8cc1-094a2506cd8a"
Title="Vydio 3"
Description="Vydio 3 (Video Confenrencing)"
OnQuickLaunch="FALSE"
Id="1038"
TemplateType="100"
Url="Lists/Vydio 3">



Notice that you can have as many ListInstance as required by your business requirement.




Feature receiver

A feature can also include a reference to a feature receiver which job consist of handle the following four events: FeatureActivated, FeatureDeactivating, FeatureInstalled, FeatureUninstalling

FeatureDeactiving has been used to have an easy way of cleaning the List created.

public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
{
//throw new Exception("The method or operation is not implemented.");
using (SPWeb currentSite = properties.Feature.Parent as SPWeb)
{
try
{
SPList vydio1 = currentSite.Lists["Vydio 1"];
vydio1.Delete();
SPList vydio2 = currentSite.Lists["Vydio 2"];
vydio2.Delete();
SPList vydio3 = currentSite.Lists["Vydio 3"];
vydio3.Delete();
currentSite.Update();
}
catch (Exception s) { }
}
}

Check the entire solutions at: Macmillan.Greenroom.ListTemplate.

Other references:

http://karinebosch.wordpress.com/walkthroughs/create-custom-list-templates-in-caml/
http://blogit.create.pt/blogs/andrevala/archive/2008/06/17/SharePoint-2007-Deployment_3A00_-List-Instance-Features.aspx

http://platinumdogs.wordpress.com/2009/09/23/creating-a-sharepoint-list-template-using-a-feature/

Friday 8 January 2010

Redirecting to another view based on CurrentUser

What a nightmare!




Today I came accross a scenario where I thought to myself "Man! I am dead here".





I needed to allow certain user to view a SP List differently than other user.




Hopefully, Sharepoint come with the concept of Views. Thus I had to create different views to achieve that. One of these view would filter the view based on the current user by using the token [ME]. To achieve one need to create a new view and then go to the section "Filter". Once there you can associate a field to be equal to [Me]. This is a great trick to show only task item or doc belonging to the current user.





Then I had to cover the second part of my scenario allow certain user to see the same list in full. They could have been trained to select the "All Task" view, but you know how user are. This will kill their user experience. So this needed to be done automatically, without the user knowing anything of it!




So for that I created a web part with the following code:


private HttpContext current;




public UserToListView()
{
current = HttpContext.Current;
}




protected override void CreateChildControls()
{
base.CreateChildControls();
string siteRedirectionUrl = string.Format("AllItems.aspx");

if (IsCurrentUserMemberOfThatGroup())
{
SPUtility.Redirect(siteRedirectionUrl, SPRedirectFlags.Default, current);
}
}





private bool IsCurrentUserMemberOfThatGroup()
{
SPWeb web = SPContext.Current.Web;
int yourGroupId = web.Groups["TheNameOfYourGroup"].ID;

if (web.IsCurrentUserMemberOfGroup(yourGroupId ))
{
return true;
}
else
{
return false;
}
}




Then I added and hidden the web part in my SP List Default view. To add the web part, just click on site setting and then edit page.





Anytime some of open this list, the code in the web part will run and if the current user is part of the group declared then the current page would be redirected from yourcurrentdomain/yourview.aspx to yourcurrentdomain/yourredirectedview.aspx





That's it enjoy!

Seve

Wednesday 4 November 2009

Reset All sites to site definition (gosted) Programatically

If you like me need to reset your migrated page to site definition you can:

1) bother yourself with using SharePoint Designer and change the customized page to uncostomized...one by one.

2) go to the site and under site setting click on the "Reset to site definition" where you will be able to reset a site or all the site under a site collection.

3) if you want a quick and reusable solution, create some code using web service model and let the Sharepoint object model work for you. Create a winForm with 3 textbox (txtSiteUrl,txtUsername,txtPassword) and 1 button. Add a web reference (Wss3).Then add the following code

Here is the code:

private void StartProcess()
{
// Declare and initialize a variable for the Lists Web Service.
Wss3.Webs WebsService = new Wss3.Webs();

if (txtSiteUrl.Text != "")
WebsService.Url = txtSiteUrl.Text + "/_vti_bin/Webs.asmx";
try
{
WebsService.Credentials = new System.Net.NetworkCredential(txtUsername.Text, txtPassword.Text, "DOMAIN_NAME_OF_THE_USER");

/* Declare an XmlNode object and initialize it with the XML response from
the GetListItems method.*/

System.Xml.XmlNode nodeListItems = WebsService.GetWebCollection();

System.Xml.XmlNamespaceManager mgr = new System.Xml.XmlNamespaceManager(nodeListItems.OwnerDocument.NameTable);
mgr.AddNamespace("wb", "http://schemas.microsoft.com/sharepoint/soap/");

System.Xml.XmlNodeList nodes = nodeListItems.SelectNodes("//wb:Web", mgr);

foreach (System.Xml.XmlNode node in nodes)
{
string url = node.Attributes["Url"].Value;
ResetToSiteDefition(url);
}

MessageBox.Show("Validation Completed");
}
catch (System.Net.WebException webException)
{
MessageBox.Show("Please, Verify the Credential", "Error StartProcess", MessageBoxButtons.OK, MessageBoxIcon.Error);

}
catch (SoapServerException soapException)
{
MessageBox.Show("Please, Verify the Url", "Error StartProcess", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

private void ResetToSiteDefition(string url)
{
Wss3.Webs WebsService = new Wss3.Webs();

try
{
WebsService.Credentials = new System.Net.NetworkCredential(txtUsername.Text, txtPassword.Text, "DOMAIN_NAME_OF_THE_USER");


if (!string.IsNullOrEmpty(url))
{
WebsService.Url = string.Format("{0}/_vti_bin/Webs.asmx", url);
WebsService.RevertAllFileContentStreams();
}
}
catch (System.Net.WebException webException)
{
MessageBox.Show("Please, Verify the Credential", "Error StartProcess", MessageBoxButtons.OK, MessageBoxIcon.Error);

}
catch (SoapServerException soapException)
{
MessageBox.Show("Please, Verify the Url", "Error StartProcess", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

Migrating WSS2 to WSS3

Hi All,

Migrating from Wss2 to Wss3 is always a bit tedious. You go through manuals and instruction and they go quite deep into the ocean. Headacke! I‘ll say.

Anyway, I was migrating from wss2 to wss3 the other day and discover a much quicker procedure.

1 1 Backup your content database used by Wss2 (as a safety measure, and a copy will be used for migration).

2 Restore it into your SQL Server of choice. This could be the current one but you will need, I guess, to rename it somehow.

3 Install Net 3.0 and Wss3 (sp3 if you want) into your Front End server.

4 Download and run the prescan.exe (download if wss3 has not provided it for you) on the box. NOT SURE THIS STEP IS REALLY NEEDED WHEN WSS2 IS NOT INSTALLED ON THE SAME BOX. BUT WHAT THE HEIK!

5 Then create a Web application using the Sharepoint Administrator site.

6 Then use the stsadm addcontentdb:

stsadm -o addcontentdb -url urlToTheWebApplicationCreated -databasename theNameOfYourWss2ContentDatabase -databaseserver theNameOfTheSQLServer –[databaseuser usernameWhohasAccessToDatabase -password passwordOfTheUsername]. (open a window command and go to the bin folder under the 12 hives)

Notice that username and password will ONLY work if the SQL Server Database has allowed mixed login. If it is only Window authentication, DO NOT PROVIDES the username and password as part of the stsadm command.

After adding the content database to your web application successfully, go to your Sharepoint Administrator page and under “application management” click on “Web application list” then click on the created “Web application”. Then click on “Content Database” and remove the content database which has 0 as value of the Current number of sites.

Then that’s should be it fox!
Enjoy!!!

Severin

Thursday 17 September 2009

Naughty WebResource.axd!!!

There is an issue, which some of us have experienced whit the javascript error when you hover Sharepoint menu. Which I guess is annoying but fine enough! However when things gets nasty is not being able to create anything such as groups, sub website, etc because of a postback issue.

Anyway there are a lot of stuff out there advising different steps such as unchecking the "Verify if file exist" at the .axd extension in IIS. But for some of us this is already unchecked. Then there is the web.config trick with the trick. But then for a lot of us it does not work. There are futher trick...but what happen if all of these DOES NOT work. well you stuck in the dark..crying perhaps:)

Think over doing the stuff programatically? Forget that! you do not to go that far!!!

Well let me give you a trick which might not resolve all you problem but at least keep you going.

The interesting think with asp.net page (which are what Sharepoint page are) is that they often use a Master.page. This master page is using the core.js file. So guess what! when going to edit that file.

So please go to this folder C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033

then open the core.js file with your favorite editor.

Then copy the following into the end of this file:

Thats it! you should be able to create group, website. It wont resolve every javascript error (SP Menu)
But it keeps you going.

Let me know, how it went!

/*WebResource.axd*/

function WebForm_PostBackOptions(eventTarget, eventArgument, validation, validationGroup, actionUrl, trackFocus, clientSubmit) {
this.eventTarget = eventTarget;
this.eventArgument = eventArgument;
this.validation = validation;
this.validationGroup = validationGroup;
this.actionUrl = actionUrl;
this.trackFocus = trackFocus;
this.clientSubmit = clientSubmit;
}
function WebForm_DoPostBackWithOptions(options) {
var validationResult = true;
if (options.validation) {
if (typeof(Page_ClientValidate) == 'function') {
validationResult = Page_ClientValidate(options.validationGroup);
}
}
if (validationResult) {
if ((typeof(options.actionUrl) != "undefined") && (options.actionUrl != null) && (options.actionUrl.length > 0)) {
theForm.action = options.actionUrl;
}
if (options.trackFocus) {
var lastFocus = theForm.elements["__LASTFOCUS"];
if ((typeof(lastFocus) != "undefined") && (lastFocus != null)) {
if (typeof(document.activeElement) == "undefined") {
lastFocus.value = options.eventTarget;
}
else {
var active = document.activeElement;
if ((typeof(active) != "undefined") && (active != null)) {
if ((typeof(active.id) != "undefined") && (active.id != null) && (active.id.length > 0)) {
lastFocus.value = active.id;
}
else if (typeof(active.name) != "undefined") {
lastFocus.value = active.name;
}
}
}
}
}
}
if (options.clientSubmit) {
__doPostBack(options.eventTarget, options.eventArgument);
}
}
var __pendingCallbacks = new Array();
var __synchronousCallBackIndex = -1;
function WebForm_DoCallback(eventTarget, eventArgument, eventCallback, context, errorCallback, useAsync) {
var postData = __theFormPostData +
"__CALLBACKID=" + WebForm_EncodeCallback(eventTarget) +
"&__CALLBACKPARAM=" + WebForm_EncodeCallback(eventArgument);
if (theForm["__EVENTVALIDATION"]) {
postData += "&__EVENTVALIDATION=" + WebForm_EncodeCallback(theForm["__EVENTVALIDATION"].value);
}
var xmlRequest,e;
try {
xmlRequest = new XMLHttpRequest();
}
catch(e) {
try {
xmlRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e) {
}
}
var setRequestHeaderMethodExists = true;
try {
setRequestHeaderMethodExists = (xmlRequest && xmlRequest.setRequestHeader);
}
catch(e) {}
var callback = new Object();
callback.eventCallback = eventCallback;
callback.context = context;
callback.errorCallback = errorCallback;
callback.async = useAsync;
var callbackIndex = WebForm_FillFirstAvailableSlot(__pendingCallbacks, callback);
if (!useAsync) {
if (__synchronousCallBackIndex != -1) {
__pendingCallbacks[__synchronousCallBackIndex] = null;
}
__synchronousCallBackIndex = callbackIndex;
}
if (setRequestHeaderMethodExists) {
xmlRequest.onreadystatechange = WebForm_CallbackComplete;
callback.xmlRequest = xmlRequest;
xmlRequest.open("POST", theForm.action, true);
xmlRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
xmlRequest.send(postData);
return;
}
callback.xmlRequest = new Object();
var callbackFrameID = "__CALLBACKFRAME" + callbackIndex;
var xmlRequestFrame = document.frames[callbackFrameID];
if (!xmlRequestFrame) {
xmlRequestFrame = document.createElement("IFRAME");
xmlRequestFrame.width = "1";
xmlRequestFrame.height = "1";
xmlRequestFrame.frameBorder = "0";
xmlRequestFrame.id = callbackFrameID;
xmlRequestFrame.name = callbackFrameID;
xmlRequestFrame.style.position = "absolute";
xmlRequestFrame.style.top = "-100px"
xmlRequestFrame.style.left = "-100px";
try {
if (callBackFrameUrl) {
xmlRequestFrame.src = callBackFrameUrl;
}
}
catch(e) {}
document.body.appendChild(xmlRequestFrame);
}
var interval = window.setInterval(function() {
xmlRequestFrame = document.frames[callbackFrameID];
if (xmlRequestFrame && xmlRequestFrame.document) {
window.clearInterval(interval);
xmlRequestFrame.document.write("");
xmlRequestFrame.document.close();
xmlRequestFrame.document.write('
');
xmlRequestFrame.document.close();
xmlRequestFrame.document.forms[0].action = theForm.action;
var count = __theFormPostCollection.length;
var element;
for (var i = 0; i < count; i++) {
element = __theFormPostCollection[i];
if (element) {
var fieldElement = xmlRequestFrame.document.createElement("INPUT");
fieldElement.type = "hidden";
fieldElement.name = element.name;
fieldElement.value = element.value;
xmlRequestFrame.document.forms[0].appendChild(fieldElement);
}
}
var callbackIdFieldElement = xmlRequestFrame.document.createElement("INPUT");
callbackIdFieldElement.type = "hidden";
callbackIdFieldElement.name = "__CALLBACKID";
callbackIdFieldElement.value = eventTarget;
xmlRequestFrame.document.forms[0].appendChild(callbackIdFieldElement);
var callbackParamFieldElement = xmlRequestFrame.document.createElement("INPUT");
callbackParamFieldElement.type = "hidden";
callbackParamFieldElement.name = "__CALLBACKPARAM";
callbackParamFieldElement.value = eventArgument;
xmlRequestFrame.document.forms[0].appendChild(callbackParamFieldElement);
if (theForm["__EVENTVALIDATION"]) {
var callbackValidationFieldElement = xmlRequestFrame.document.createElement("INPUT");
callbackValidationFieldElement.type = "hidden";
callbackValidationFieldElement.name = "__EVENTVALIDATION";
callbackValidationFieldElement.value = theForm["__EVENTVALIDATION"].value;
xmlRequestFrame.document.forms[0].appendChild(callbackValidationFieldElement);
}
var callbackIndexFieldElement = xmlRequestFrame.document.createElement("INPUT");
callbackIndexFieldElement.type = "hidden";
callbackIndexFieldElement.name = "__CALLBACKINDEX";
callbackIndexFieldElement.value = callbackIndex;
xmlRequestFrame.document.forms[0].appendChild(callbackIndexFieldElement);
xmlRequestFrame.document.forms[0].submit();
}
}, 10);
}
function WebForm_CallbackComplete() {
for (var i = 0; i < __pendingCallbacks.length; i++) {
callbackObject = __pendingCallbacks[i];
if (callbackObject && callbackObject.xmlRequest && (callbackObject.xmlRequest.readyState == 4)) {
WebForm_ExecuteCallback(callbackObject);
if (!__pendingCallbacks[i].async) {
__synchronousCallBackIndex = -1;
}
__pendingCallbacks[i] = null;
var callbackFrameID = "__CALLBACKFRAME" + i;
var xmlRequestFrame = document.getElementById(callbackFrameID);
if (xmlRequestFrame) {
xmlRequestFrame.parentNode.removeChild(xmlRequestFrame);
}
}
}
}
function WebForm_ExecuteCallback(callbackObject) {
var response = callbackObject.xmlRequest.responseText;
if (response.charAt(0) == "s") {
if ((typeof(callbackObject.eventCallback) != "undefined") && (callbackObject.eventCallback != null)) {
callbackObject.eventCallback(response.substring(1), callbackObject.context);
}
}
else if (response.charAt(0) == "e") {
if ((typeof(callbackObject.errorCallback) != "undefined") && (callbackObject.errorCallback != null)) {
callbackObject.errorCallback(response.substring(1), callbackObject.context);
}
}
else {
var separatorIndex = response.indexOf("|");
if (separatorIndex != -1) {
var validationFieldLength = parseInt(response.substring(0, separatorIndex));
if (!isNaN(validationFieldLength)) {
var validationField = response.substring(separatorIndex + 1, separatorIndex + validationFieldLength + 1);
if (validationField != "") {
var validationFieldElement = theForm["__EVENTVALIDATION"];
if (!validationFieldElement) {
validationFieldElement = document.createElement("INPUT");
validationFieldElement.type = "hidden";
validationFieldElement.name = "__EVENTVALIDATION";
theForm.appendChild(validationFieldElement);
}
validationFieldElement.value = validationField;
}
if ((typeof(callbackObject.eventCallback) != "undefined") && (callbackObject.eventCallback != null)) {
callbackObject.eventCallback(response.substring(separatorIndex + validationFieldLength + 1), callbackObject.context);
}
}
}
}
}
function WebForm_FillFirstAvailableSlot(array, element) {
var i;
for (i = 0; i < array.length; i++) {
if (!array[i]) break;
}
array[i] = element;
return i;
}
var __nonMSDOMBrowser = (window.navigator.appName.toLowerCase().indexOf('explorer') == -1);
var __theFormPostData = "";
var __theFormPostCollection = new Array();
function WebForm_InitCallback() {
var count = theForm.elements.length;
var element;
for (var i = 0; i < count; i++) {
element = theForm.elements[i];
var tagName = element.tagName.toLowerCase();
if (tagName == "input") {
var type = element.type;
if ((type == "text" || type == "hidden" || type == "password" ||
((type == "checkbox" || type == "radio") && element.checked)) &&
(element.id != "__EVENTVALIDATION")) {
WebForm_InitCallbackAddField(element.name, element.value);
}
}
else if (tagName == "select") {
var selectCount = element.options.length;
for (var j = 0; j < selectCount; j++) {
var selectChild = element.options[j];
if (selectChild.selected == true) {
WebForm_InitCallbackAddField(element.name, element.value);
}
}
}
else if (tagName == "textarea") {
WebForm_InitCallbackAddField(element.name, element.value);
}
}
}
function WebForm_InitCallbackAddField(name, value) {
var nameValue = new Object();
nameValue.name = name;
nameValue.value = value;
__theFormPostCollection[__theFormPostCollection.length] = nameValue;
__theFormPostData += WebForm_EncodeCallback(name) + "=" + WebForm_EncodeCallback(value) + "&";
}
function WebForm_EncodeCallback(parameter) {
if (encodeURIComponent) {
return encodeURIComponent(parameter);
}
else {
return escape(parameter);
}
}
var __disabledControlArray = new Array();
function WebForm_ReEnableControls() {
if (typeof(__enabledControlArray) == 'undefined') {
return false;
}
var disabledIndex = 0;
for (var i = 0; i < __enabledControlArray.length; i++) {
var c;
if (__nonMSDOMBrowser) {
c = document.getElementById(__enabledControlArray[i]);
}
else {
c = document.all[__enabledControlArray[i]];
}
if ((typeof(c) != "undefined") && (c != null) && (c.disabled == true)) {
c.disabled = false;
__disabledControlArray[disabledIndex++] = c;
}
}
setTimeout("WebForm_ReDisableControls()", 0);
return true;
}
function WebForm_ReDisableControls() {
for (var i = 0; i < __disabledControlArray.length; i++) {
__disabledControlArray[i].disabled = true;
}
}
function WebForm_FireDefaultButton(event, target) {
if (event.keyCode == 13) {
var src = event.srcElement || event.target;
if (!src || (src.tagName.toLowerCase() != "textarea")) {
var defaultButton;
if (__nonMSDOMBrowser) {
defaultButton = document.getElementById(target);
}
else {
defaultButton = document.all[target];
}
if (defaultButton && typeof(defaultButton.click) != "undefined") {
defaultButton.click();
event.cancelBubble = true;
if (event.stopPropagation) event.stopPropagation();
return false;
}
}
}
return true;
}
function WebForm_GetScrollX() {
if (__nonMSDOMBrowser) {
return window.pageXOffset;
}
else {
if (document.documentElement && document.documentElement.scrollLeft) {
return document.documentElement.scrollLeft;
}
else if (document.body) {
return document.body.scrollLeft;
}
}
return 0;
}
function WebForm_GetScrollY() {
if (__nonMSDOMBrowser) {
return window.pageYOffset;
}
else {
if (document.documentElement && document.documentElement.scrollTop) {
return document.documentElement.scrollTop;
}
else if (document.body) {
return document.body.scrollTop;
}
}
return 0;
}
function WebForm_SaveScrollPositionSubmit() {
if (__nonMSDOMBrowser) {
theForm.elements['__SCROLLPOSITIONY'].value = window.pageYOffset;
theForm.elements['__SCROLLPOSITIONX'].value = window.pageXOffset;
}
else {
theForm.__SCROLLPOSITIONX.value = WebForm_GetScrollX();
theForm.__SCROLLPOSITIONY.value = WebForm_GetScrollY();
}
if ((typeof(this.oldSubmit) != "undefined") && (this.oldSubmit != null)) {
return this.oldSubmit();
}
return true;
}
function WebForm_SaveScrollPositionOnSubmit() {
theForm.__SCROLLPOSITIONX.value = WebForm_GetScrollX();
theForm.__SCROLLPOSITIONY.value = WebForm_GetScrollY();
if ((typeof(this.oldOnSubmit) != "undefined") && (this.oldOnSubmit != null)) {
return this.oldOnSubmit();
}
return true;
}
function WebForm_RestoreScrollPosition() {
if (__nonMSDOMBrowser) {
window.scrollTo(theForm.elements['__SCROLLPOSITIONX'].value, theForm.elements['__SCROLLPOSITIONY'].value);
}
else {
window.scrollTo(theForm.__SCROLLPOSITIONX.value, theForm.__SCROLLPOSITIONY.value);
}
if ((typeof(theForm.oldOnLoad) != "undefined") && (theForm.oldOnLoad != null)) {
return theForm.oldOnLoad();
}
return true;
}
function WebForm_TextBoxKeyHandler(event) {
if (event.keyCode == 13) {
var target;
if (__nonMSDOMBrowser) {
target = event.target;
}
else {
target = event.srcElement;
}
if ((typeof(target) != "undefined") && (target != null)) {
if (typeof(target.onchange) != "undefined") {
target.onchange();
event.cancelBubble = true;
if (event.stopPropagation) event.stopPropagation();
return false;
}
}
}
return true;
}
function WebForm_TrimString(value) {
return value.replace(/^\s+|\s+$/g, '')
}
function WebForm_AppendToClassName(element, className) {
var currentClassName = ' ' + WebForm_TrimString(element.className) + ' ';
className = WebForm_TrimString(className);
var index = currentClassName.indexOf(' ' + className + ' ');
if (index === -1) {
element.className = (element.className === '') ? className : element.className + ' ' + className;
}
}
function WebForm_RemoveClassName(element, className) {
var currentClassName = ' ' + WebForm_TrimString(element.className) + ' ';
className = WebForm_TrimString(className);
var index = currentClassName.indexOf(' ' + className + ' ');
if (index >= 0) {
element.className = WebForm_TrimString(currentClassName.substring(0, index) + ' ' +
currentClassName.substring(index + className.length + 1, currentClassName.length));
}
}
function WebForm_GetElementById(elementId) {
if (document.getElementById) {
return document.getElementById(elementId);
}
else if (document.all) {
return document.all[elementId];
}
else return null;
}
function WebForm_GetElementByTagName(element, tagName) {
var elements = WebForm_GetElementsByTagName(element, tagName);
if (elements && elements.length > 0) {
return elements[0];
}
else return null;
}
function WebForm_GetElementsByTagName(element, tagName) {
if (element && tagName) {
if (element.getElementsByTagName) {
return element.getElementsByTagName(tagName);
}
if (element.all && element.all.tags) {
return element.all.tags(tagName);
}
}
return null;
}
function WebForm_GetElementDir(element) {
if (element) {
if (element.dir) {
return element.dir;
}
return WebForm_GetElementDir(element.parentNode);
}
return "ltr";
}
function WebForm_GetElementPosition(element) {
var result = new Object();
result.x = 0;
result.y = 0;
result.width = 0;
result.height = 0;
if (element.offsetParent) {
result.x = element.offsetLeft;
result.y = element.offsetTop;
var parent = element.offsetParent;
while (parent) {
result.x += parent.offsetLeft;
result.y += parent.offsetTop;
var parentTagName = parent.tagName.toLowerCase();
if (parentTagName != "table" &&
parentTagName != "body" &&
parentTagName != "html" &&
parentTagName != "div" &&
parent.clientTop &&
parent.clientLeft) {
result.x += parent.clientLeft;
result.y += parent.clientTop;
}
parent = parent.offsetParent;
}
}
else if (element.left && element.top) {
result.x = element.left;
result.y = element.top;
}
else {
if (element.x) {
result.x = element.x;
}
if (element.y) {
result.y = element.y;
}
}
if (element.offsetWidth && element.offsetHeight) {
result.width = element.offsetWidth;
result.height = element.offsetHeight;
}
else if (element.style && element.style.pixelWidth && element.style.pixelHeight) {
result.width = element.style.pixelWidth;
result.height = element.style.pixelHeight;
}
return result;
}
function WebForm_GetParentByTagName(element, tagName) {
var parent = element.parentNode;
var upperTagName = tagName.toUpperCase();
while (parent && (parent.tagName.toUpperCase() != upperTagName)) {
parent = parent.parentNode ? parent.parentNode : parent.parentElement;
}
return parent;
}
function WebForm_SetElementHeight(element, height) {
if (element && element.style) {
element.style.height = height + "px";
}
}
function WebForm_SetElementWidth(element, width) {
if (element && element.style) {
element.style.width = width + "px";
}
}
function WebForm_SetElementX(element, x) {
if (element && element.style) {
element.style.left = x + "px";
}
}
function WebForm_SetElementY(element, y) {
if (element && element.style) {
element.style.top = y + "px";
}
}