Sharepoint notes Sep 2010

Add Website

create a site.it will create application pool with the same name.

now go to application pools.

Right click on sharepoint central administration .Select advanced settings
Now go to process model ->identity. give the system admin credentials.

You have to do the same for the above created website.

Then only our created site can acces sharepoint features.
Otherwise “object reference problem” arises at spweb,splist etc.

——————————————
display = none html: doesnt display the text

display : block display the text

logical && (and) : T T – T
                   T F – F
                   F T – F
            F F – F

logical || (or)   T T – T
    T F – T
                  F T – T
                  F F – f
——–

http://www.dotnetcurry.com/ShowArticle.aspx?ID=155&AspxAutoDetectCookieSupport=1

How To Access One UserControl from Another Using ASP.NET
 
Recently, I came across a post in the asp.net forums, where a user was trying to access the value of a dropdownlist kept in one UserControl, from another UserControl. There were quiet a number of suggestions given, however either they were too complex or not explained well. In this article, we will see how easy it is to achieve this requirement.
Step 1: Create a new ASP.NET website. Right click the project > Add New Item > Web User Control. Give it the name ‘ControlA’. Similarly create another user control and give it the name ‘ControlB’.
Step 2: We will now create a dropdownlist(ddlItems) in ‘ControlB’ and access the selected value of the dropdownlist in ‘ControlA’.
To do so, drag and drop a dropdownlist in the usercontrol ‘ControlB’ and add some items to it. The source will look similar to the following:
<%@ Control Language=”C#” AutoEventWireup=”true” CodeFile=”ControlB.ascx.cs” Inherits=”ControlB” %>
<asp:DropDownList ID=”ddlItems” runat=”server”>
    <asp:ListItem>Item A</asp:ListItem>
    <asp:ListItem>Item B</asp:ListItem>
    <asp:ListItem>Item C</asp:ListItem>
</asp:DropDownList>
 
Also expose the dropdownlist as a property as shown below:
C#
public partial class ControlB : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
 
    }
 
    public DropDownList ControlB_DDL
      {
            get
            {
                return this.ddlItems;
            }
     }
}
VB.NET
Public Partial Class ControlB
      Inherits System.Web.UI.UserControl
      Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
 
      End Sub
 
      Public ReadOnly Property ControlB_DDL() As DropDownList
                  Get
                        Return Me.ddlItems
                  End Get
      End Property
End Class
Step 3: Now drag and drop a TextBox(txtDDLValue) and a Button(btnDDLValue) on to the usercontrol ‘ControlA’.
Another crucial part is to add a Reference directive of ‘ControlB’ in ‘ControlA’. Since the user controls are compiled into assemblies, adding a reference enables ‘ControlA’ to access the methods and properties of ‘ControlB’. The source will look similar to the following:
<%@ Control Language=”C#” AutoEventWireup=”true” CodeFile=”ControlA.ascx.cs” Inherits=”ControlA” %>
<%@ Reference VirtualPath=”~/ControlB.ascx” %>
 
 
<asp:TextBox ID=”txtDDLValue” runat=”server”></asp:TextBox>
<br />
<br />
<asp:Button ID=”btnDDLValue” runat=”server” OnClick=”btnDDLValue_Click” Text=”Get DropDown Value” />
 
Add the following code to the codebehind of ‘ControlA’
C#
public partial class ControlA : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
 
    }
 
    protected void btnDDLValue_Click(object sender, EventArgs e)
    {
        ControlB ctrlB = (ControlB)Page.FindControl(“cB”);
        DropDownList ddl = ctrlB.ControlB_DDL;
        txtDDLValue.Text = ddl.SelectedValue;
    }
}
VB.NET
Public Partial Class ControlA
      Inherits System.Web.UI.UserControl
      Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
 
      End Sub
 
      Protected Sub btnDDLValue_Click(ByVal sender As Object, ByVal e As EventArgs)
            Dim ctrlB As ControlB = CType(Page.FindControl(“cB”), ControlB)
            Dim ddl As DropDownList = ctrlB.ControlB_DDL
            txtDDLValue.Text = ddl.SelectedValue
———-

Download files from SP doc library

SPListlist=web.Lists[“MyDocumentLibrary”]; 
SPListItemitem=list.Items[1]; 
SPFilefile=item.File; 
System.IO.Directory.CreateDirectory(“C:\\TempFolder”); 
stringtempPath=”C:\\TempFolder”; 
Byte[]tempFile=file.OpenBinary(); 
if(tempFile.Length>=0) 

FileStreamfs=newFileStream(tempPath+file.Name,FileMode.OpenOrCreate,FileAccess.Write); 
fs.Write(tempFile,0,tempFile.Length); 
fs.Close(); 
}
http://www.sharepointdev.net/sharepoint–development-programming/issue-while-downloading-file-programmatically-using-spfile-56085.shtml
———————————–
usesubmitbehavior = true will give u the provision to submit the page on click of enter key

—————————

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: