开发者

Sharepoint 2007 placeholder issue

I've created a simple placeHolder for some extra javascript in jQuery - The issue is that the placeHolder is within some script tags and therefore isn't recognized by Sharepoint designer.

The page works correctly, so it hasn't bothered me until now, since you can't touch any part of the design view, without fixing the issue.

My code looks something like this in the master te开发者_StackOverflow社区mplate:

<script type="text/javascript>
  $(document).ready(function(){ 
    <asp:ContentPlaceHolder id="PlaceHolderjQuery" runat="server" />
  });
</script>

Is there a way to make this work correctly, so that the placeholder is actually recognized by Sharepoint Designer?

Thanks for the help!


I understood that you are trying to call a JavaScript function that is defined inside the PlaceHolder. But your code wont work as the PlaceHolder is a Server Control and pushing it as a child element of the some other tag wont work. Script tag is a client processing tag. So What I would suggest is to change the logic as below.

In the master page I will have a JavaScript to call a function by default.

<script type="text/javascript>
  $(document).ready(function(){ 
       myOnLoadFunction();
  });
</script>

And I will define the content Place Holder with a dummy function

<asp:ContentPlaceHolder id="PlaceHolderjQuery" runat="server">
 <script type="text/javascript>function myOnLoadFunction(){ //do nothing }</script>
</asp:ContentPlaceHolder>

Now in your content page you can define

<asp:Content ID="javascript" ContentPlaceHolderID="PlaceHolderjQuery" runat="server">
 <script type="text/javascript>function myOnLoadFunction(){ alert('Hello jQuery');   }</script>
</asp:Content>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜