Hi all
I have a problem with the asp:TreeView-Control. I have a website wehre I use the javascriptfuction "__doPostPack" do get information about the ui-element that was clicked
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
this works very well. But when I insert asp:TreeView on the webpage...
<asp:TreeView runat="server" ImageSet="Arrows" NodeIndent="0" OnTreeNodePopulate="Node_Populate">
<HoverNodeStyle Font-Underline="True" ForeColor="#6666AA" />
<Nodes>
<asp:TreeNode Text="Module und Dialoge" Value="0" PopulateOnDemand="true" SelectAction="None"/>
</Nodes>
<NodeStyle Font-Names="Tahoma" Font-Size="10pt" ForeColor="Black" />
</asp:TreeView>
... already now the __doPostPack seems not to be fired anymore for every control on this webpage because every time __EVENTTARGET and __EVENTARGUMENT is clear.
Does anybody know something about this problem?
Edith: Complete code
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Web_Lokalisierung.Models.EditNewViewModel>" %>
<asp:Content ID="Title" ContentPlaceHolderID="TitleContent" runat="server">
JOMOsoft M Lokalisierung
</asp:Content>
<asp:Content ID="Main" ContentPlaceHolderID="MainContent" runat="server">
<h2>
Bearbeitung [<%=ViewData["Slave"] %>]</h2>
<asp:Panel ID="Panel2" runat="server" BackColor="LightGray" HorizontalAlign="Right">
<%=Html.ActionLink("[zurück]","Chose")%>
</asp:Panel>
<form id="Form1" runat="server">
<div class="aspNetHidden">
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__LASTFOCUS" id="__LASTFOCUS" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTE0MjA5MTc2MzVkZM2XOunXa05eDa/N53CJ2xekpEBT4Wcm0UB2FrQijzS/" />
<input type="hidden" name="__MASTER" id="Hidden1" value="<%=ViewData["Master"] %>" />
<input type="hidden" name="__SLAVE" id="Hidden2" value="<%=ViewData["Slave"] %>" />
<input type="hidden" name="__FOCUS" id="Hidden3" value="<%=ViewData["Focus"] %>" />
<input type="hidden" name="__FILTER" id="Hidden4" value="<%=ViewData["Filter"] %>" />
</div>
<script type="text/javascript">
//<![CDATA[
</script>
<script runat="server">
void Node_Populate(object sender, System.Web.UI.WebControls.TreeNodeEventArgs e)
{
if (e.Node.ChildNodes.Count == 0)
{
switch (e.Node.Depth)
{
case 0:
FillModules(e.Node);
break;
case 1:
FillDialoges(e.Node);
break;
}
}
}
void FillModules(TreeNode node)
{
string modul = String.Empty;
foreach (Web_Lokalisierung.Models.ModulDialogObject item in Model.TreeViewData)
{
if (modul != item.ModulName)
{
TreeNode newNode = new TreeNode();
newNode.Text = item.ModulName;
newNode.Value = item.ModulName;
newNode.PopulateOnDemand = true;
newNode.SelectAction = TreeNodeSelectAction.Select;
node.ChildNodes.Add(newNode);
}
modul = item.ModulName;
}
}
void FillDialoges(TreeNode node)
{
foreach (Web_Lokalisierung.Models.ModulDialogObject item in Model.TreeViewData)
{
if (item.ModulName == node.Value)
{
if (item.DialogName != String.Empty)
{
TreeNode newNode = new TreeNode();
newNode.Text = item.DialogName;
newNode.Value = item.ModulName + "_" + item.DialogName;
newNode.PopulateOnDemand = false;
newNode.SelectAction = TreeNodeSelectAction.Select;
node.ChildNodes.Add(newNode);
}
}
}
}
</script>
<asp:Table runat="server" >
<asp:TableRow VerticalAlign="Top">
<asp:TableCell>
<div id="treeDiv" style="width: 190px; height: 650px; overflow-x: auto; overflow-y: auto;
background: #E8EEF4">
<asp:TreeView ID="TreeView1" runat="server" ImageSet="Arrows" NodeIndent="0" OnTreeNodePopulate="Node_Populate">
<HoverNodeStyle Font-Underline="True" ForeColor="#6666AA" />
<Nodes>
<asp:TreeNode Text="Module und Dialoge" Value="0" PopulateOnDemand="true" SelectAction="None" />
</Nodes>
<NodeStyle Font-Names="Tahoma" Font-Size="10pt" ForeColor="Black" />
</asp:TreeView>
</div>
<%--<asp:Panel ID="Panel3" runat="server" BackColor="#E8EEF4" Width="180">
</asp:Panel>--%>
</asp:TableCell>
<asp:TableCell>
<div id="listDiv" style="width: 400px; height: 600px; overflow-x: auto;
overflow-y: auto">
<select size="<%=Model.UidDictionary.Count()+1 %>" name="masterList" style="min-width: 400px" id="MainContent_masterList1"
onchange="javascript:setTimeout('__doPostBack(\'masterList\',\'\')', 0)">
<%foreach (KeyValuePair<string, bool> item in Model.UidDictionary)
{
if (item.Value == true)
{%>
<option <%if (item.Key == ViewData["Focus"].ToString() || Model.UidDictionary.Count()==1){ %>selected="selected"
<%} %> style="background-color: #dff5e6" value="<%=item.Key%>">
<%=item.Key%></option>
<%}
else
{ %>
<option <%if (item.Key == ViewData["Focus"].ToString()|| Model.UidDictionary.Count()==1){ %>selected="selected"
<%} %> style="background-color: #f7d8df" value="<%=item.Key%>">
<%=item.Key%></option>
<%}
}%>
</select>
</div>
<asp:Table runat="server">
<asp:TableRow>
<asp:TableCell HorizontalAlign="Center" BorderColor="Transparent">
<div style="background-color:#dff5e6;width:100px">übersetzt</div>
</asp:TableCell>
<asp:TableCell HorizontalAlign="Center" BorderColor="Transparent">
<div style="background-color:#f7d8df;width:100px">nicht übersetzt</div>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</asp:TableCell>
<asp:TableCell BorderColor="Transparent" Width="800" Style="height: 600px">
<asp:Table runat="server" >
<asp:TableRow>
<asp:TableCell BorderColor="Transparent" Height="40" Width="800">
<input type="text" readonly="readonly" value="<%=ViewData["FocusUid"] %>" style="width:inherit;font-weight:bold" />
<br />
<input type="text" readonly="readonly" value="<%=ViewData["MasterTextProperty"] %>" style="width:200" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell BorderColor="Transparent" Height="40" Width="800">
<%=ViewData["master"] %>
<br />
<textarea name="taMaster" readonly="readonly" style="width:inherit" cols="1" rows="10"><%=ViewData["MasterText"] %></textarea>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell BorderColor="Transparent" Height="40" Width="800">
<%=ViewData["Slave"] %>
<br />
<textarea name="taSlave" style="width:inherit" cols="1" rows="10"><%=ViewData["SlaveText"] %></textarea>
<br />
<input type="submit" value="Datensatz abspeichern" style="width:inherit" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow Height="100" >
<asp:TableCell BorderColor="Transparent">
<font color="red"><b><%=ViewData["Fail"] %></b></font>
<font color="green"><b><%=ViewData["Sucsess"] %></b></font>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</form>
<asp:Panel ID="Panel1" runat="server" BackColor="LightGray" HorizontalAlign="Right">
<%=Html.ActionLink("[zurück]","Chose")%>
</asp:Panel>
</asp:Content
>