convert asp.net code to WebPart code issue

George2
  • convert asp.net code to WebPart code issue George2

    Possible Duplicate:
    How to use JavaScript and CSS in a web part?

    I am using SharePoint Server 2007 Enterprise with Windows Server 2008 Enterprise. I am developing using VSTS 2008 + C# + .Net 3.5 + ASP.Net. I have the following code which works correctly in ASP.Net (aspx) and I want to implement the same function in a WebPart and deploy into a page of SharePoint publishing portal site.

    Any ideas how to implement? My major confusion is how to deal with the code in the head part of the following code? Any reference code or document?

    Here is the aspx code I am using,

    <!doctype html>
    <html lang="en">
    <head>
        <title>Test</title>
        <link type="text/css" href="tabcontrol/themes/base/ui.all.css" rel="stylesheet" />
        <script type="text/javascript" src="tabcontrol/jquery-1.3.2.js"></script>
        <script type="text/javascript">
            $(function() {
                $("#tabs").tabs();
            });
        </script>
    </head>
    <body>
    
    <div class="demo">
    
    <div id="tabs">
        <ul>
            <li><a href="#tabs-1">tab1</a></li>
            <li><a href="#tabs-2">tab2</a></li>
        </ul>
        <div id="tabs-1">
            <p>tab1 info</p>
        </div>
        <div id="tabs-2">
            <p>tab2 info</p>
        </div>
    </div>
    
    </div>
    
    </body>
    </html>
    

  • What type of answer are you expecting here that is different than your previous question which was answered?

    How to use JavaScript and CSS in a web part?

  • This shouldn't be any problem creating in a Web Part

    1. Create your div and lists as ASP.NET controls in CreatChildControls() or just render plain ol' html
    2. Use this.Page.ClientScript.RegisterClientScriptInclude(...) and this.Page.ClientScript.RegisterClientScriptBlock(...) to register your scripts
    3. Have fun!

    /WW

  • Here's the approach I use to go from web page to web part.

    1. Build traditional ASP.NET web page in a ASP.NET web application
    2. Convert the web page to a user control.
    3. Create a thin web part that loads the user control.
    4. Deploy the assembly to the GAC, and the control to the 12 hive.

    Here's my blog post that describes the approach.

Tags
web-part javascript jquery
Related questions and answers
  • I am using SharePoint Server 2007 Enterprise with Windows Server 2008 Enterprise. And I am developing using VSTS 2008 + C# + .Net 3.5 + ASP.Net + JavaScript (jQuery). I met with the following...? &lt;link type="text/css" href="_layouts/test/themes/base/ui.all.css" rel="stylesheet" /&gt; &lt;script type="text/javascript" src="_layouts/test/jquery-1.3.2.js"&gt;&lt;/script>; &lt;script type="text/javascript" src="_layouts/test/ui/ui.core.js"&gt;&lt;/script>; &lt;script type="text/javascript" src="_layouts/test/ui/ui.tabs.js"&gt;&lt;/script>; &lt;link type="text/css" href="_layouts

  • ; &lt;td width="75%" class="ms-formbody"&gt; &lt;SharePoint:FormField runat="server" id="ff1{$Pos}" ControlMode="Edit" FieldName...; &lt;SharePoint:FieldDescription runat="server" id="ff1description{$Pos}" FieldName="Holiday_x0020_Request_x0020_Stat" ControlMode="Edit"/&gt; &lt;/td>...;/td> &lt;td width="75%" class="ms-formbody"&gt; &lt;SharePoint:FormField runat="server" id="ff2{$Pos}" ControlMode="Edit" FieldName="Comments1

  • to refer to related css/javascript files? BTW: the existing code of css/javascript/Webpart is from existing aspx code and I am migrating aspx code to a Webpart. The code works in aspx. Currently my code looks like this, &lt;link type="text/css" href="../../themes/test.css" rel="stylesheet" /&gt; &lt;script type="text/javascript" src="../../test.js"&gt;&lt;/script>; ...I am using SharePoint Server 2007 Enterprise with Windows Server 2008 Enterprise. I am using publishing portal template. I am developing using VSTS 2008 + C# + .Net 3.5 + ASP.Net. And I want

  • Hiding Left Nav user1155

    ="ms-quicklaunchheader"&gt;&lt;SharePoint:SPLinkButton id="idNavLinkViewAll" runat="server" NavigateUrl="~site/_layouts/viewlsts.aspx" Text="&lt;%$Resources:wss,quiklnch_allcontent%&gt;" accesskey..." RootContextObject="Web" IncludeDiscussionFolders="true" /&gt; &lt;SharePoint:SPRememberScroll runat="server" id="TreeViewRememberScroll...="LeftNavTableCell" runat="server"&gt; &lt;table cellpadding="0" cellspacing="0" id="LeftNav"&gt; &lt;tr> &lt;td style="width:301px; text-align:left; vertical-align:top

  • I am using SharePoint Server 2007 Enterprise with Windows Server 2003 R2 Enterprise. I am developing using VSTS 2008 + C# + .Net 3.5 + IIS 6.0. I have put a simple aspx page into layout folder... manager. I am not in Active Directory or Windows domain environment. I have enabled permission to anonymous users for the whole SharePoint site. Any ideas what is wrong? &lt;%@ Page Language="C#" AutoEventWireup="true" %&gt; &lt;script runat="server" type="text/C#"&gt; protected void Page_Load(object sender,EventArgs e) { Response.Redirect("http://www.google.com"); } &lt;/script>; &lt

  • ','')} } }); }); &lt;/script>;&lt;div id="dialog" title="Question" style="display:none"&gt;&lt;span>&lt;/span>&lt;span>What is the Capital of Massachusetts ?&lt;/span>&lt;table id..."; btnAnswer.Click += new EventHandler(btnAnswer_Click); btnAnswer.Style.Add("display", "none"); //javascript is handling clicking Controls.Add(btnAnswer); Rendered output from the web part &lt;script language="javascript"&gt; $(document).ready(function() { $("#dialog").dialog({ bgiframe: true, height: 300, modal: true, closeOnEscape: false, width: 400, buttons: { 'Skip': function

  • where I'm programmatically trying to add it using the "Upload Web Part" feature. This is the code I'm using to add the web part: function addWebPart(serverRelativeUrl) { //var webPartXml = "&lt...I'm trying to add a custom web part (that is one I have written myself) using the new Javascipt OM available with SharePoint 2010. My solution is also running within the Sandbox. I have it working correctly for the Content Editor Web Part (based on sample code), however when I replace the Content Editor Web Part definition with one for my own web part I get the following error

  • I am using Microsoft Search Server 2008 (based on SharePoint Server 2007) + C# + .Net 3.5 + VSTS 2008 + ASP.Net to develop a web application which invokes Search Server 2008 Web Services when a button in the html page is pressed. I am using the following code to query content from Microsoft Search Server 2008. My question is how to display the search results from the DataSet retrieved? I did... = "Microsoft"; //The XML string containing the query request information //for the Web service string qXMLString = "&lt;QueryPacket xmlns='urn:Microsoft.Search.Query'&gt

  • Possible Duplicate: Integrating SharePoint user profiles with forms authentication I am using SharePoint Server 2007 Enterprise with Windows Server 2008 Enterprise. I have deployed a publishing portal. It is using a custom forms authentication solution, which is described in the following URL. I am developing using VSTS 2008 + C# + .Net 3.5 + ASP.Net + SharePoint Server 2007 SDK. http://msdn.microsoft.com/en-us/library/bb975135.aspx My question is how do I implement a user profile function if I use such a membership provider? By user profile function I mean: a logged in user could