Resolved:Use Microsoft.SharPoint namespace in Inline Code of .ASPX Page


Its 2:17 AM of night and I am working with a pop up window to use in sharepoint due to this i took a .aspx page provided in visual studio so i have to wrote some inline code that uses Microsoft.SharePoint name-space. Below is the code snippet for utilizing Microsoft.SharePoint in inline code:

<%@ Page Language=”C#” %>

<%@ Assembly Name=”Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>
<%@ Import Namespace=”System” %>
<%@ Import Namespace=”System.Data” %>
<%@ Import Namespace=”Microsoft.SharePoint” %>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;

<script runat=”server”>
SPSite site;
SPWeb web;
SPList list;
string webName = “sop”;
string listName = “Publications”;
DataTable dtPublications;
SPQuery searchQuery;
protected void Page_Load(object sender, EventArgs e)
{
site = SPContext.Current.Site;
web = site.OpenWeb(webName);
list = web.Lists[listName];
searchQuery = new SPQuery();
searchQuery.Query = “<Where><Eq><FieldRef Name=’Title_x0020_of_x0020_publication’ /><Value Type=’Text’>” + Request.QueryString[“Title”].ToString() + “</Value></Eq></Where>”;

dtPublications = list.GetItems(searchQuery).GetDataTable();
if (dtPublications != null || dtPublications.Rows.Count!=0)
{
foreach (DataRow item in dtPublications.Rows)
{
this.ltrTOC.Text = item[“TOC”].ToString();
}
}
else
{
this.ltrTOC.Text = “No Table of Contents Found !”;
}
}
</script>

Happy Programming 🙂

Advertisements

Leave a Comment

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