2011年2月20日 星期日

asp.net menu 和 flash

在aspx上放了一個falsh object , 瀏覽時卻發現原本的sitemap menu下拉時, 卻被蓋在falsh下,
一直都把焦點放在z-index的修改上
看到 Tsung's Blog ...哈哈, 我也恍然大悟了. 感謝他

主要是在flash object加入一個設定

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%"
        codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0">
        <param name="MOVIE" value="../Yoshinoya/BrandSingleSeason.swf">
        <param name="PLAY" value="true">
        <param name="LOOP" value="true">
        <param name="WMODE" value="transparent">
        <param name="QUALITY" value="high">
        <embed src="BrandSingleSeason.swf" width="100%" height="100%" play="true" loop="true"
            wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">
    </embed>
    </object>

另外,由Tsung's Blog延伸找到的範例也有詳細的說明 Z-Index and Flash.


後來,又查得JQuery提供一個swf plugin的套件,使用這個插件就無menu被蓋住的問題了.
所以後來參考範例網站後,就改用這個方式 ,程式碼也很簡潔

    <script type="text/javascript" src="../Scripts/jquery.swfobject.1-1-1.min.js"></script>     
    <script type="text/javascript">
        function displayFlash(type) {
            $('#myFlash').flash({ swf: type, height: '100%', width: '100%' });
        }
    </script> 
    <div id="myFlash" >
    </div>

進階的使用方法可參考

jQuery SWFObject Plugin

2011年2月9日 星期三

取用BugNet的HtmlEditor Provider

在BugNet Issue維護中,Descriptioncomment是使用html編輯器的方式讓我們可以輸入html格式的文字,我覺得挺好用的.

在BugNet的source code查看這段的做法,發現是利用provider的方式做的,先把相關的srouce code 抽出來,試著放入自已專案用的程式碼中

1.下載最新的BugNet souce code, 目前版本是0.8.276.0, 解壓縮後,複製以下目錄
 \BugNET-0.8.276-Source\src\Library\Providers\HtmlEditorProviders 

2.建立一個新方案,把 \BugNET-0.8.276-Source\src\Library\Providers\HtmlEditorProviders\下的四個專案都加入, 如果有需要,可以修改一下專案的Assembly Name及相關的namespace,不然build出來的dll名稱會是BugNet開頭的dll

3.build 完後,分別將專案內的dll複製出來,add reference 到自已的website 專案中,
同時也複製 以下目錄檔案及檔案

 a. \BugNET-0.8.276-Source\src\BugNET_WAP\Providers\HtmlEditorProviders
 b. \BugNET-0.8.276-Source\src\BugNET_WAP\UserControls\HtmlEditor.ascxHtmlEditor.ascx.cs、HtmlEditor.ascx.designer.cs

3.開啟自已website專案的web.config檔, 加入以下

 <configSections>
<section name="HtmlEditorProvider" type="BugNET.Providers.HtmlEditorProviders.HtmlEditorConfiguration, BugNET.Providers.HtmlEditorProviders" requirePermission="false" allowDefinition="MachineToApplication" />
 </configSections>


<HtmlEditorProvider defaultProvider="CkHtmlEditorProvider">
    <providers>
      <add name="TextboxHtmlEditorProvider" type="BugNET.Providers.HtmlEditorProviders.TextboxHtmlEditorProvider, BugNET.Providers.TextboxHtmlEditorProvider" Height="250" Width="100%" />
      <add name="FckHtmlEditorProvider" type="BugNET.Providers.HtmlEditorProviders.FckHtmlEditorProvider, BugNET.Providers.FckHtmlEditorProvider" Height="250" Width="100%" ToolbarSet="Default" Skin="Silver" providerPath="~\Providers\HtmlEditorProviders\fckeditor\" />
      <add name="CkHtmlEditorProvider" type="BugNET.Providers.HtmlEditorProviders.CkHtmlEditorProvider, BugNET.Providers.CkHtmlEditorProvider" Height="250" Width="100%" Toolbar="Basic" providerPath="~\Providers\HtmlEditorProviders\CKEditor\" />
    </providers>
  </HtmlEditorProvider>


<pages enableSessionState="true" theme="Default">
      <controls>
          <add tagPrefix="bn" tagName="HtmlEditor" src="~/UserControls/HtmlEditor.ascx" />
 </controls>
    </pages>


以上紅字部份是依自已的需求做更改的

4.建立一個測試網頁testHtmlEditor.aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="testHtmlEditor.aspx.cs" Inherits="Issues.testHtmlEditor" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    test
  <bn:HtmlEditor id="EditCommentHtmlEditor" Height="200" runat="server" />       
</asp:Content>

執行後就可以看到html editor元件了.

BugNet預設的html editor toolbar是使用"Basic", 這個定義你可在
\BugNET-0.8.276-Source\src\BugNET_WAP\Providers\HtmlEditorProviders\CKEditor\config.js 自行修改,以下是原本的定義
config.toolbar_Basic =
[   
    ['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print', 'SpellChecker', 'Scayt'],
    ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],   
    '/',
    ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
    ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
    ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
    ['BidiLtr', 'BidiRtl' ],
    ['Link','Unlink','Anchor'],
    ['Image','Table','HorizontalRule'],
    '/',
    ['Styles','Format','Font','FontSize'],
    ['TextColor','BGColor'],
    ['Maximize', 'ShowBlocks','-','About']
];


BugNet中還有不少可學習的點,沒什麼想法的人可以玩看看

publish error allowDefinition='MachineToApplication'

一個老舊的aspx web form專案,調了一些功能建置成功,但進行部署時顯示以下錯誤。 在應用程式層級之外使用註冊為 allowDefinition='MachineToApplication' 的區段發生錯誤。錯誤的原因可能是虛擬目錄尚未在 IIS 中設定為...