Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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>
share|improve this question
add comment

marked as duplicate by Alex Angas Jan 13 '10 at 1:03

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

3 Answers

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

http://www.sharepointoverflow.com/questions/1024/how-to-use-javascript-and-css-in-a-web-part

share|improve this answer
1  
Oh i agree completely –  Anders Rask Jan 12 '10 at 14:32
    
My confusion is how to use register script API in my specific case to register the js and css files? Any ideas? –  George2 Jan 13 '10 at 9:12
add comment

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

share|improve this answer
1  
which basicly was what i suggested in the other question ;-) –  Anders Rask Jan 12 '10 at 21:33
    
My confusion is how to use register script API in my specific case to register the js and css files? Any ideas or samples? –  George2 Jan 13 '10 at 9:13
    
As I said in my reply use the RegisterClientScriptBlock() or RegisterCilentScriptInclude(), those two will help you out with this... –  Wictor Wilen MCA MCM MVP Jan 13 '10 at 12:13
add comment

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.

share|improve this answer
    
My confusion is how to use register script API in my specific case to register the js and css files? Any ideas? –  George2 Jan 13 '10 at 9:13
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.