-1

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>

3 Answers 3

3

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?

2
  • 1
    Oh i agree completely Commented Jan 12, 2010 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
    Commented Jan 13, 2010 at 9:12
1

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

3
  • 1
    which basicly was what i suggested in the other question ;-) Commented Jan 12, 2010 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
    Commented Jan 13, 2010 at 9:13
  • As I said in my reply use the RegisterClientScriptBlock() or RegisterCilentScriptInclude(), those two will help you out with this... Commented Jan 13, 2010 at 12:13
1

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.

1
  • My confusion is how to use register script API in my specific case to register the js and css files? Any ideas?
    – George2
    Commented Jan 13, 2010 at 9:13

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