Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将asp.net代码转换为Web部件代码问题_C#_.net_Asp.net_Sharepoint 2007_Web Parts - Fatal编程技术网

C# 将asp.net代码转换为Web部件代码问题

C# 将asp.net代码转换为Web部件代码问题,c#,.net,asp.net,sharepoint-2007,web-parts,C#,.net,Asp.net,Sharepoint 2007,Web Parts,我正在将SharePoint Server 2007 Enterprise与Windows Server 2008 Enterprise一起使用。我正在使用VSTS2008+C++.NET3.5+ASP.Net进行开发。我有以下在ASP.Net(aspx)中正常工作的代码,我希望在Web部件中实现相同的功能,并部署到SharePoint发布门户网站的页面中 有什么办法可以实施吗?我的主要困惑是如何处理下面代码的开头部分中的代码?有参考代码或文件吗 这是我正在使用的aspx代码 <!doct

我正在将SharePoint Server 2007 Enterprise与Windows Server 2008 Enterprise一起使用。我正在使用VSTS2008+C++.NET3.5+ASP.Net进行开发。我有以下在ASP.Net(aspx)中正常工作的代码,我希望在Web部件中实现相同的功能,并部署到SharePoint发布门户网站的页面中

有什么办法可以实施吗?我的主要困惑是如何处理下面代码的开头部分中的代码?有参考代码或文件吗

这是我正在使用的aspx代码

<!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>

试验
$(函数(){
$(“#制表符”).tabs();
});
表1信息

表2信息

提前感谢,, 乔治

检查此链接

如果您需要帮助,请告诉我,我可以为您提供一个Web部件示例


要包含css或js文件,您可以执行以下操作

 protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);



            ClientScriptManager cs = Page.ClientScript;

            string includeTemplate = "<link rel='stylesheet' text='text/css' href='{0}' />";
            string includeLocation = Page.ClientScript.GetWebResourceUrl(this.GetType(), "App_Themes.MyButtons.css");
            LiteralControl include = new LiteralControl(String.Format(includeTemplate, includeLocation));
            Page.Header.Controls.Add(include);

            includeTemplate = "<link rel='stylesheet' text='text/css' href='{0}' />";
            includeLocation = Page.ClientScript.GetWebResourceUrl(this.GetType(), "App_Themes.MyMainModalDialog.css");
            include = new LiteralControl(String.Format(includeTemplate, includeLocation));
            Page.Header.Controls.Add(include);


        }
protected override void OnLoad(事件参数e)
{
基础荷载(e);
ClientScriptManager cs=Page.ClientScript;
字符串includeTemplate=“”;
字符串includeLocation=Page.ClientScript.GetWebResourceUrl(this.GetType(),“App_Themes.MyButtons.css”);
LiteralControl include=新的LiteralControl(String.Format(includeTemplate,includeLocation));
页面.标题.控件.添加(包括);
includeTemplate=“”;
includeLocation=Page.ClientScript.GetWebResourceUrl(this.GetType(),“App_Themes.MyMainModalDialog.css”);
include=新的LiteralControl(String.Format(includeTemplate,includeLocation));
页面.标题.控件.添加(包括);
}
在这个示例中,我动态地包含了MyMainModalDialog.css和MyButtons.css。对于css,您可以使用和:

我忘了除了ClientScriptManager或Page.Header.Controls.Add()之外,是否还有其他方法来处理自定义javascript。有一个类,但它的运行方式似乎与CssLink的工作方式不同


另外,我认为格式化脚本
$(function(){$(“#tabs”).tabs()})
应该挂接到page.load事件,而不是
块中。

我的困惑是如何在我的特定情况下使用register script API来注册js和css文件?有什么想法吗?
// Custom CSS (fix the URL as necessary)
Microsoft.SharePoint.WebControls.CssLink cssLink =
    new Microsoft.SharePoint.WebControls.CssLink(); 
cssLink.DefaultUrl = "/tabcontrol/themes/base/ui.all.css";
this.Page.Header.Controls.Add(cssLink);