Hi,
In general we know the page life cycle as follows...
Page request :
The page request occurs before the page life cycle begins. When the page is requested by a user, ASP.NET determines whether the page needs to be parsed and compiled (therefore beginning the life of a page), or whether a cached version of the page can be sent in response without running the page.
Start :
In the start step, page properties such as Request and Response are set. At this stage, the page also determines whether the request is a postback or a new request and sets the IsPostBack property. Additionally, during the start step, the page's UICulture property is set.
Page initialization :
During page initialization, controls on the page are available and each control's UniqueID property is set. Any themes are also applied to the page. If the current request is a postback, the postback data has not yet been loaded and control property values have not been restored to the values from view state.
Load :
During load, if the current request is a postback, control properties are loaded with information recovered from view state and control state.
Validation :
During validation, the Validate method of all validator controls is called, which sets the IsValid property of individual validator controls and of the page.
Postback event handling :
If the request is a postback, any event handlers are called.
Rendering :
Before rendering, view state is saved for the page and all controls. During the rendering phase, the page calls the Render method for each control, providing a text writer that writes its output to the OutputStream of the page's Response property.
Unload :
Unload is called after the page has been fully rendered, sent to the client, and is ready to be discarded. At this point, page properties such as Response and Request are unloaded and any cleanup is performed.
And in detail the difference in Page life cycle between ASP.NET 2.0 & 1.1 is shown in the following picture.
Click Here
Regards
Fauzi
Blog from a software professional, Passionate to work in latest cutting edge technologies in order to get better results in business.
Friday, May 9, 2008
Thursday, April 10, 2008
WSS 3.0 and MOSS 2007
Hi All,
As every one knows WSS & MOSS both are powerful tools provided by Microsoft. I was surfing on net to compare the key features available in WSS 3.0 vs MOSS 2007. Here is the link i came across & its really too good.
Click here
Here here the comparisons are made based on classifications like
Collaboration
Enterprise Search
Business Process Forms
Management
Enterprise Portal
Enterprise Content Management
Business Intelligence
Platform
Hope this should be helpful...
Regards
Fauzi
As every one knows WSS & MOSS both are powerful tools provided by Microsoft. I was surfing on net to compare the key features available in WSS 3.0 vs MOSS 2007. Here is the link i came across & its really too good.
Click here
Here here the comparisons are made based on classifications like
Collaboration
Enterprise Search
Business Process Forms
Management
Enterprise Portal
Enterprise Content Management
Business Intelligence
Platform
Hope this should be helpful...
Regards
Fauzi
Sunday, April 6, 2008
Tips on Capacity planning for MOSS 2007 Server
Hi
I was looking for links to find maximum number of items allowed in a List and found the following link. It has lot of information's which could be helpful for capacity & Architecture planning while setting up MOSS server.
Link to the information
Regards
Fauzi
I was looking for links to find maximum number of items allowed in a List and found the following link. It has lot of information's which could be helpful for capacity & Architecture planning while setting up MOSS server.
Link to the information
Regards
Fauzi
Tuesday, April 1, 2008
To Find and Replace a String in All Pages inside Document Library in MOSS site
Hey All,
There was an interesting issue that came across in one of moss site when it went live... actually when we edit a content of a page which has content editor webpart through rich text editor, it automatically replaces the relative URL with the fully specified URL. So when the site was moved from development to production, the URLs were still pointing to the development. So to over come this issue the following aspx file with a c# code behind was written to find for a string & replace with a specfied string in All the available pages inside the document library.
Following is its code:
**********************
In-line ASPX file
System.Text
System.Data
System.Configuration
System.Collections
System.Web
System.Web.Security
System.Web.UI
System.Web.UI.WebControls
System.Web.UI.WebControls.WebParts
System.Web.UI.HtmlControls
System.Xml
Microsoft.SharePoint
Microsoft.SharePoint.Administration
Microsoft.SharePoint.Publishing
Microsoft.SharePoint.WebPartPages
System.Runtime.InteropServices
System.IO
script runat server (inside tags)
public const int LOGON32_LOGON_INTERACTIVE = 2;
public const int LOGON32_LOGON_SERVICE = 3;
public const int LOGON32_PROVIDER_DEFAULT = 0;
[DllImport("advapi32.dll", CharSet=CharSet.Auto)]
public static extern bool LogonUser(
String lpszUserName,
String lpszDomain,
String lpszPassword,
int dwLogonType,
int dwLogonProvider,
ref IntPtr phToken
);
[DllImport("kernel32.dll", CharSet=CharSet.Auto)]
public extern static bool CloseHandle(IntPtr handle);
protected void Button1_Click(object sender, EventArgs e)
{
string user = "YOUR A/C";
string userDomain = "Your Domain";
string password = "A/C Password";
bool impersonate = true;
IntPtr userHandle = new IntPtr(0);
System.Security.Principal.WindowsImpersonationContext impersonatedUser = null;
if (impersonate)
{
bool returnValue = LogonUser(
user,
userDomain,
password,
LOGON32_LOGON_INTERACTIVE,
LOGON32_PROVIDER_DEFAULT,
ref userHandle
);
if (!returnValue)
{
throw new Exception("Invalid Username");
}
System.Security.Principal.WindowsIdentity newId = new System.Security.Principal.WindowsIdentity(userHandle);
impersonatedUser = newId.Impersonate();
}
try
{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
// We get the MOSS site URL from text box URL1.
SPSite mySite = new SPSite(URL1.Text);
SPWeb myWeb = mySite.OpenWeb();
try
{
myWeb.AllowUnsafeUpdates = true;
SPList pagesList = myWeb.Lists["Pages"];
SPListItemCollection myitems = myWeb.Lists["Pages"].Items;
foreach (SPListItem myItem in myitems)
{
SPWebPartCollection webPartCollection = myItem.File.GetWebPartCollection(Storage.Shared);
PublishingPage myPage = PublishingPage.GetPublishingPage(myItem);
foreach (Microsoft.SharePoint.WebPartPages.WebPart x in webPartCollection)
{
if (x.GetType().Name == "ContentEditorWebPart")
{
//Create an XmlElement to hold the value of the Content property.
ContentEditorWebPart ceWebPart = new ContentEditorWebPart();
//Create an XmlElement to hold the value of the Content property.
XmlDocument xmlDoc = new XmlDocument();
XmlElement xmlElement = xmlDoc.CreateElement("Content");
xmlElement.InnerText = ((ContentEditorWebPart)x).Content.InnerText.ToString();
if (xmlElement.InnerText.ToString().Contains(TextBox1.Text))
{
// We enter the text to be found in TextBox1 & the text to replace in TextBox2
xmlElement.InnerText = xmlElement.InnerText.ToString().Replace(TextBox1.Text, TextBox2.Text);
// Write the LOG details for investigation later...
StreamWriter stWriter = File.AppendText("D:\\ChangeLog.log");
stWriter.WriteLine(myItem.Url.ToString() + " - " + DateTime.Now);
stWriter.Close();
}
ceWebPart.Content = xmlElement;
((ContentEditorWebPart)x).Content = ceWebPart.Content;
webPartCollection.Web.AllowUnsafeUpdates = true;
webPartCollection.SaveChanges(x.StorageKey);
myPage.Update();
webPartCollection.Web.AllowUnsafeUpdates = false;
}
}
if (myPage.ListItem.ParentList.EnableModeration)
{
myPage.ListItem.File.Approve("");
}
}
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
finally
{
myWeb.Dispose();
mySite.Dispose();
}
});
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
finally
{
}
if (impersonate)
{
impersonatedUser.Undo();
CloseHandle(userHandle);
}
}
protected void Page_Load(object sender, EventArgs e)
{
}
script ending tag
Form starting tag
URL(TextBox)
From(TextBox)
To (TextBox)
Submit (Button on click calls Button1_Click event )
form ending tag
There was an interesting issue that came across in one of moss site when it went live... actually when we edit a content of a page which has content editor webpart through rich text editor, it automatically replaces the relative URL with the fully specified URL. So when the site was moved from development to production, the URLs were still pointing to the development. So to over come this issue the following aspx file with a c# code behind was written to find for a string & replace with a specfied string in All the available pages inside the document library.
Following is its code:
**********************
In-line ASPX file
System.Text
System.Data
System.Configuration
System.Collections
System.Web
System.Web.Security
System.Web.UI
System.Web.UI.WebControls
System.Web.UI.WebControls.WebParts
System.Web.UI.HtmlControls
System.Xml
Microsoft.SharePoint
Microsoft.SharePoint.Administration
Microsoft.SharePoint.Publishing
Microsoft.SharePoint.WebPartPages
System.Runtime.InteropServices
System.IO
script runat server (inside tags)
public const int LOGON32_LOGON_INTERACTIVE = 2;
public const int LOGON32_LOGON_SERVICE = 3;
public const int LOGON32_PROVIDER_DEFAULT = 0;
[DllImport("advapi32.dll", CharSet=CharSet.Auto)]
public static extern bool LogonUser(
String lpszUserName,
String lpszDomain,
String lpszPassword,
int dwLogonType,
int dwLogonProvider,
ref IntPtr phToken
);
[DllImport("kernel32.dll", CharSet=CharSet.Auto)]
public extern static bool CloseHandle(IntPtr handle);
protected void Button1_Click(object sender, EventArgs e)
{
string user = "YOUR A/C";
string userDomain = "Your Domain";
string password = "A/C Password";
bool impersonate = true;
IntPtr userHandle = new IntPtr(0);
System.Security.Principal.WindowsImpersonationContext impersonatedUser = null;
if (impersonate)
{
bool returnValue = LogonUser(
user,
userDomain,
password,
LOGON32_LOGON_INTERACTIVE,
LOGON32_PROVIDER_DEFAULT,
ref userHandle
);
if (!returnValue)
{
throw new Exception("Invalid Username");
}
System.Security.Principal.WindowsIdentity newId = new System.Security.Principal.WindowsIdentity(userHandle);
impersonatedUser = newId.Impersonate();
}
try
{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
// We get the MOSS site URL from text box URL1.
SPSite mySite = new SPSite(URL1.Text);
SPWeb myWeb = mySite.OpenWeb();
try
{
myWeb.AllowUnsafeUpdates = true;
SPList pagesList = myWeb.Lists["Pages"];
SPListItemCollection myitems = myWeb.Lists["Pages"].Items;
foreach (SPListItem myItem in myitems)
{
SPWebPartCollection webPartCollection = myItem.File.GetWebPartCollection(Storage.Shared);
PublishingPage myPage = PublishingPage.GetPublishingPage(myItem);
foreach (Microsoft.SharePoint.WebPartPages.WebPart x in webPartCollection)
{
if (x.GetType().Name == "ContentEditorWebPart")
{
//Create an XmlElement to hold the value of the Content property.
ContentEditorWebPart ceWebPart = new ContentEditorWebPart();
//Create an XmlElement to hold the value of the Content property.
XmlDocument xmlDoc = new XmlDocument();
XmlElement xmlElement = xmlDoc.CreateElement("Content");
xmlElement.InnerText = ((ContentEditorWebPart)x).Content.InnerText.ToString();
if (xmlElement.InnerText.ToString().Contains(TextBox1.Text))
{
// We enter the text to be found in TextBox1 & the text to replace in TextBox2
xmlElement.InnerText = xmlElement.InnerText.ToString().Replace(TextBox1.Text, TextBox2.Text);
// Write the LOG details for investigation later...
StreamWriter stWriter = File.AppendText("D:\\ChangeLog.log");
stWriter.WriteLine(myItem.Url.ToString() + " - " + DateTime.Now);
stWriter.Close();
}
ceWebPart.Content = xmlElement;
((ContentEditorWebPart)x).Content = ceWebPart.Content;
webPartCollection.Web.AllowUnsafeUpdates = true;
webPartCollection.SaveChanges(x.StorageKey);
myPage.Update();
webPartCollection.Web.AllowUnsafeUpdates = false;
}
}
if (myPage.ListItem.ParentList.EnableModeration)
{
myPage.ListItem.File.Approve("");
}
}
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
finally
{
myWeb.Dispose();
mySite.Dispose();
}
});
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
finally
{
}
if (impersonate)
{
impersonatedUser.Undo();
CloseHandle(userHandle);
}
}
protected void Page_Load(object sender, EventArgs e)
{
}
script ending tag
Form starting tag
URL(TextBox)
From(TextBox)
To (TextBox)
Submit (Button on click calls Button1_Click event )
form ending tag
Monday, March 31, 2008
Your own custom error page for MOSS 2007 site
Hey All,
I had a requirment to show custom error page in my MOSS 2007 site. I tried couple of options like changing the node customErrors "On" & specified URL for DefaultRedirect in Web.config And editing the custom error locations in the properties of the site.
Both of them did not work & i tried the steps mentioned in the following URL.
Click Here
It worked fine :)
I had a requirment to show custom error page in my MOSS 2007 site. I tried couple of options like changing the node customErrors "On" & specified URL for DefaultRedirect in Web.config And editing the custom error locations in the properties of the site.
Both of them did not work & i tried the steps mentioned in the following URL.
Click Here
It worked fine :)
Saturday, March 29, 2008
Ajax based Dynamic User Control for Menu from Master Page in MOSS 2007 Site
Hi All,
I had an interesting requirement in one of my previous project. A single control (user control) will display the Menu appropriate to the respective page the user has browsed currently. Moreover, in future if any new page is added to the site by site-administrator. The Menu automatically gets updated & display with the new link added.
For example, the classification in the website is like below.
Home
A Page
A1 Page
A11 Page
A12 Page
A2 Page
A21 Page
B Page
B1 Page
B2 Page
B21 Page
B22 Page
So when the user is in section-A either in page A or page A12 He will be seeing the Menus built for all the links in A Section & in case if he is in Section-B, all the available page in B section are shown to him in menu.
In addition, there are many branches similar to the hierarchy shown above & this functionality is achieved with a single User control, which binds dynamically. The Ajax based dynamic user control for the menu is placed in Master page of the site so that it is available in all the pages & you can view the above-mentioned functionality implemented in
www.kockw.com
The Steps to implement & the source code of the user control is placed in the document URL given below.
Elaborated Description for IE users
Elaborated Description for Firefox users
Any queries regarding implementation are welcome...
Thanks
Fauzi
I had an interesting requirement in one of my previous project. A single control (user control) will display the Menu appropriate to the respective page the user has browsed currently. Moreover, in future if any new page is added to the site by site-administrator. The Menu automatically gets updated & display with the new link added.
For example, the classification in the website is like below.
Home
A Page
A1 Page
A11 Page
A12 Page
A2 Page
A21 Page
B Page
B1 Page
B2 Page
B21 Page
B22 Page
So when the user is in section-A either in page A or page A12 He will be seeing the Menus built for all the links in A Section & in case if he is in Section-B, all the available page in B section are shown to him in menu.
In addition, there are many branches similar to the hierarchy shown above & this functionality is achieved with a single User control, which binds dynamically. The Ajax based dynamic user control for the menu is placed in Master page of the site so that it is available in all the pages & you can view the above-mentioned functionality implemented in
www.kockw.com
The Steps to implement & the source code of the user control is placed in the document URL given below.
Elaborated Description for IE users
Elaborated Description for Firefox users
Any queries regarding implementation are welcome...
Thanks
Fauzi
Thursday, March 13, 2008
C# code talking to Active Directory
For one of my clients work the requirment is like that we have users fill out Infopath forms 2007. So there needs to be a code behind (c#) to validate the user in the domain to find from which group he is from.... doing that it came my mind how will i get all the email Ids from a domain... Yup following is the code the talks to your Active Directory in the domain & gets all the Email IDs available....
Belive me, i am not a spammer.... i just do these things for fun :)
using System.DirectoryServices;
namespace ConsoleApplication1
{
class Program
{
static void Main (string[] args)
{
SAM d = new SAM();
string f = d.GetEmail("*");
}
}
class SAM
{
public string GetEmail(string ntname)
{
DirectorySearcher objsearch = new DirectorySearcher();
string strrootdse = objsearch.SearchRoot.Path;
DirectoryEntry objdirentry = new DirectoryEntry(strrootdse);
objsearch.Filter = "(& (mailnickname=" + ntname.Trim() + ")(objectClass=user))";
objsearch.SearchScope = System.DirectoryServices.SearchScope.Subtree;
objsearch.PropertiesToLoad.Add("mail");
objsearch.PropertyNamesOnly = true;
SearchResultCollection colresults = objsearch.FindAll();
string arl = "";
foreach (SearchResult objresult in colresults)
{
arl = arl + objresult.GetDirectoryEntry().Properties["mail"].Value + ";";
}
if (arl.Length > 0)
arl = arl.Substring(0, arl.Length - 1);
objsearch.Dispose();
return arl;
}
}
}
Belive me, i am not a spammer.... i just do these things for fun :)
using System.DirectoryServices;
namespace ConsoleApplication1
{
class Program
{
static void Main (string[] args)
{
SAM d = new SAM();
string f = d.GetEmail("*");
}
}
class SAM
{
public string GetEmail(string ntname)
{
DirectorySearcher objsearch = new DirectorySearcher();
string strrootdse = objsearch.SearchRoot.Path;
DirectoryEntry objdirentry = new DirectoryEntry(strrootdse);
objsearch.Filter = "(& (mailnickname=" + ntname.Trim() + ")(objectClass=user))";
objsearch.SearchScope = System.DirectoryServices.SearchScope.Subtree;
objsearch.PropertiesToLoad.Add("mail");
objsearch.PropertyNamesOnly = true;
SearchResultCollection colresults = objsearch.FindAll();
string arl = "";
foreach (SearchResult objresult in colresults)
{
arl = arl + objresult.GetDirectoryEntry().Properties["mail"].Value + ";";
}
if (arl.Length > 0)
arl = arl.Substring(0, arl.Length - 1);
objsearch.Dispose();
return arl;
}
}
}
Subscribe to:
Posts (Atom)