私はマスターページに関連付けられたページを持っています。マスターページでは、CSSのリンクをheadセクションに置き、jqueryスクリプトタグと関数を含むスクリプトを入れてグリッドを切り替えますが、動かない場合はグリッドを切り替えます。私がアイテムをクリックしたときにshowhideを呼び出すことさえないように見えます。ここでなぜこのスクリプトはマスターページから実行されていませんか?
は、マスターページの抜粋である:ここで
<head runat="server">
<title></title>
<link href="MainLayout.css" rel="stylesheet" type="text/css" />
<link href="ajaxtab.css" rel="stylesheet" type="text/css" />
<link href="dialog.css" rel="stylesheet" type="text/css" />
<link href="grid.css" rel="stylesheet" type="text/css" />
<link href="pager.css" rel="stylesheet" type="text/css" />
<link href="subgrid.css" rel="stylesheet" type="text/css" />
<script src="jquery-1.3.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
//master: id of div element that contains the information about master data
//details: id of div element wrapping the details grid
function showhide(master, detail) {
//First child of master div is the image
var src = $(master).children()[0].src;
//Switch image from (+) to (-) or vice versa.
if (src.endsWith("plus.png"))
src = src.replace('plus.png', 'minus.png');
else
src = src.replace('minus.png', 'plus.png');
//Set new image
$(master).children()[0].src = src;
//Toggle expand/collapse
$(detail).slideToggle("normal");
}
</script>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
はaspxページ内のonclickイベントにshowhide機能が含まれているdiv要素である:ここでは
<div class="searchgroup"
id='<%#String.Format("master{0}",Container.DataItemIndex)%>'
onclick='showhide(<%#String.Format("\"#master{0}\"",Container.DataItemIndex)%>
,
<%#String.Format("\"#detail{0}\"",Container.DataItemIndex) %>)'>
<asp:Image ID="imgCollapsible"
CssClass="first"
ImageUrl="plus.png"
Style="margin-right: 5px;"
runat="server" />
<span class="searchheader"><%#Eval("Business")%></span>
</div>
は、それが生成するHTMLですマスターとディテールのdivのために:
//master div
<div class="searchgroup"
id='master0'
onclick='showhide("#master0","#detail0")'>
<img id="ctl00_ContentPanel_gvMaster_ctl02_imgCollapsible"
class="first" src="plus.png"
style="border-width:0px;margin-right: 5px;" />
<span class="searchheader">ABC</span>
</div>
//details div
<div id='detail0' class="searchdetail">
<div>
<table class="searchgrid"
id="ctl00_ContentPanel_gvMaster_ctl02_gvDtails">
<tr>
<th>Status</th>
<tr class="searchrow">
<td>2</td>
</tr>
</table>
</div>
</div>
私はjQueryの作業を得ることができませんでしたし、私はrunnました時間の余裕がないので、私はajaxコントロールツールキットから折りたたみ可能なパネルの外部を使用することに決めました。私が時間を取ると、私はJQueryの問題を調査します。これまでのすべての提案に感謝します。誰かがそれ以上持っているなら、私に知らせてください。
(それはJSファイルをCSSの細かい動作しますが、ではない)あなたはマスターページ上のJavaScript URLを解決する必要が私に語りましたショーハイドに。実際のコードを扱うときに識別するのがずっと速いものがあります。 – eglasius
私の考えは正確に - レンダリングされたhtmlを表示し、まだ立ち往生している場合は、htmlの関連部分を含むようにあなたの投稿を編集します。 –