Only asp.net code search
Re: Some AJAX questions.
gt1329a
Re: Treeview with check boxes in an update panel
maduranga001

 Yes.I have enabled JavaScript.Please see my .aspx file here.I have use an update panel.If user click on  a check box, label's text should be change without refreshing the page.(Used Ajax update panel).Then I have used a JavaScript.If I use this then i cant expand tree nodes.Please see my code and help me to solve this problem.

 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="SearchStep2.aspx.cs" Inherits="Search_SearchStep2" EnableEventValidation="true" %>

<%@ Register src="../usercontrols/searchWizard.ascx" tagname="searchWizard" tagprefix="uc1" %>

<%@ Register src="../usercontrols/searchFooter.ascx" tagname="searchFooter" tagprefix="uc1" %>

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Untitled Page</title>
   
<script type="text/javascript">
     function PostbackOnCheck()
    {
   
       // var isNav = (window.navigator.appName.toLowerCase().indexOf("netscape")>=0);
        //var o;
        //if (isNav && e != null)
       // o = e.target;
       // else
       // o = window.event.srcElement;
        //if (o.tagName == 'INPUT' && o.type == 'checkbox' && o.name != null && o.name.indexOf('CheckBox') > -1)
        __doPostBack('<%=treeview1.ClientID%>',"");
    }
   
        function OnTreeClick(evt)
                    {
                   
                   __doPostBack('<%=treeview1.ClientID%>',"");
                   
                    var src = window.event != window.undefined ? window.event.srcElement : evt.target;
                    var isChkBoxClick = (src.tagName.toLowerCase() == "input" && src.type == "checkbox");
                    if(isChkBoxClick)
                    {
                   
                    
                    
                    var parentTable = GetParentByTagName("table", src);
                    var nxtSibling = parentTable.nextSibling;
                    if(nxtSibling && nxtSibling.nodeType == 1)//check if nxt sibling is not null & is an element node
                    {
                    if(nxtSibling.tagName.toLowerCase() == "div") //if node has children
                    {
                    //check or uncheck children at all levels
                    CheckUncheckChildren(parentTable.nextSibling, src.checked);
                    }
                    }
                    //check or uncheck parents at all levels
                    CheckUncheckParents(src, src.checked);
                    }
                    }
                    function CheckUncheckChildren(childContainer, check)
                    {
                    var childChkBoxes = childContainer.getElementsByTagName("input");
                    var childChkBoxCount = childChkBoxes.length;
                    for(var i = 0; i<childChkBoxCount; i++)
                    {
                    childChkBoxes[i].checked = check;
                    }
                    }
                    function CheckUncheckParents(srcChild, check)
                    {
                    var parentDiv = GetParentByTagName("div", srcChild);
                    var parentNodeTable = parentDiv.previousSibling;

                    if(parentNodeTable)
                    {
                    var checkUncheckSwitch;

                    if(check) //checkbox checked
                    {
                    var isAllSiblingsChecked = AreAllSiblingsChecked(srcChild);
                    if(isAllSiblingsChecked)
                    checkUncheckSwitch = true;
                    else
                    return; //do not need to check parent if any(one or more) child not checked
                    }
                    else //checkbox unchecked
                    {
                    checkUncheckSwitch = false;
                    }

                    var inpElemsInParentTable = parentNodeTable.getElementsByTagName("input");
                    if(inpElemsInParentTable.length > 0)
                    {
                    var parentNodeChkBox = inpElemsInParentTable[0];
                    parentNodeChkBox.checked = checkUncheckSwitch;
                    //do the same recursively
                    CheckUncheckParents(parentNodeChkBox, checkUncheckSwitch);
                    }
                    }
                    }
                    function AreAllSiblingsChecked(chkBox)
                    {
                    var parentDiv = GetParentByTagName("div", chkBox);
                    var childCount = parentDiv.childNodes.length;
                    for(var i=0; i<childCount; i++)
                    {
                    if(parentDiv.childNodes[i].nodeType == 1) //check if the child node is an element node
                    {
                    if(parentDiv.childNodes[i].tagName.toLowerCase() == "table")
                    {
                    var prevChkBox = parentDiv.childNodes[i].getElementsByTagName("input")[0];
                    //if any of sibling nodes are not checked, return false
                    if(!prevChkBox.checked)
                    {
                    return false;
                    }
                    }
                    }
                    }
                    return true;
                    }
                    //utility function to get the container of an element by tagname
                    function GetParentByTagName(parentTagName, childElementObj)
                    {
                    var parent = childElementObj.parentNode;
                    while(parent.tagName.toLowerCase() != parentTagName.toLowerCase())
                    {
                    parent = parent.parentNode;
                    }
                    return parent;
                 }
                   
                   
        function TreeviewExpandCollapseAll(treeViewId, expandAll)
         {
        
             __doPostBack();
        
              var displayState = (expandAll == true ? "none" : "block");
              var treeView = document.getElementById(treeViewId);
              if(treeView)
              {
                  var treeLinks = treeView.getElementsByTagName("a");
                  var nodeCount = treeLinks.length;
                      
                  for(i=0;i<nodeCount;i++)
                  {
                       if(treeLinks[i].firstChild.tagName)
                       {
                           if(treeLinks[i].firstChild.tagName.toLowerCase() == "img")
                           {
                               var currentToggleLink = treeLinks[i];
                               var childContainer = GetParentByTagName("table", currentToggleLink).nextSibling;
                               if (childContainer.style.display == displayState)
                                {
                                   eval(currentToggleLink.href);
                                }
                          }
                       }
                  }//for loop ends
              }
        }

         //utility function to get the container of an element by tagname
        function GetParentByTagName(parentTagName, childElementObj)
        {
           var parent = childElementObj.parentNode;
           while(parent.tagName.toLowerCase() != parentTagName.toLowerCase())
           {
              parent = parent.parentNode;
           }
         return parent;
        }
     
   
        function expandAll(treeViewId)
    {
         var treeView = document.getElementById(treeViewId);
         var treeLinks = treeView.getElementsByTagName("a");
         var j = true;
        
         __doPostBack();
        // __doPostBack('<%=treeview1.ClientID%>',"");
        
         for(i=0;i<treeLinks.length;i++)
         {
              if(treeLinks[i].firstChild.tagName == "IMG")
              {
                var node = treeLinks[i];
                var level = parseInt(treeLinks[i].id.substr(treeLinks[i].id.length - 1),10);
                var childContainer = document.getElementById(treeLinks[i].id + "Nodes");
              
               if(j)
                {
                    if(childContainer.style.display == "none")
                    TreeView_ToggleNode(eval(treeViewId +"_Data"),level,node,'r',childContainer);
                    j = false;
                }
                else
                {
                    if(childContainer.style.display == "none")
                    TreeView_ToggleNode(eval(treeViewId +"_Data"),level,node,'l',childContainer);
                }
              }
          }
   }                
   
</script>


    <style type="text/css">
        #Search
        {
            height: 170px;
        }
        #DropDown
        {
            height: 35px;
            width: 799px;
            top: 303px;
            left: 8px;
            position: absolute;
        }
        #Menus
        {
            height: 86px;
            width: 794px;
        }
        #divtree
        {
            width: 798px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true">
</asp:ScriptManager>

<asp:UpdatePanel ID="upanel1" runat="server">
         <Triggers>
       <%--<asp:PostBackTrigger ControlID="treeview1" />--%>
                 <asp:AsyncPostBackTrigger ControlID="treeview1" EventName="TreeNodeCheckChanged" />
        </Triggers>
    <ContentTemplate>
     
    <div style="border: thin solid #000080; width: 769px">
  
        <div style="text-align:right; width: 793px; height: 6px;">
         <asp:Label ID="Label1" runat="server" Text="LIVE COUNT" Font-Size="Larger"
            ForeColor="#990000"></asp:Label>&nbsp;
        <asp:Label ID="lblLivecount" runat="server" Font-Size="Larger"
            ForeColor="#990000">0</asp:Label>
    </div>
        <div id="Menus">
            <asp:Button ID="Button6" runat="server" BackColor="#99FF33"
                BorderColor="#66FF33" ForeColor="#003300" Height="39px" Text="Button"
                Width="186px" />
    <uc1:searchWizard ID="searchWizard1" runat="server" />
</div>
       
       
        <div id = "FilterOptions"
            style="border: medium solid #800000; width: 397px; height: 93px; margin-left: 399px; margin-top: 0px; position: relative; top: 1px; left: -18px;">
            <b>Filter Options</b><br />
            Keyword Search&nbsp;
            <asp:TextBox ID="TextBox4" runat="server" style="margin-left: 1px"
                Width="160px"></asp:TextBox>
&nbsp;<asp:Button ID="Button4" runat="server" Text="Find It" Height="24px"
                style="margin-left: 1px" />
            <br />
            Postcode Search&nbsp;
            <asp:TextBox ID="TextBox5" runat="server" style="margin-left: 1px" Width="79px"></asp:TextBox>
            <asp:TextBox ID="TextBox6" runat="server"
                style="margin-left: 3px" Width="72px"></asp:TextBox>
&nbsp;<asp:Button ID="Button5" runat="server" Text="Find It" Height="24px" />
            <br />
        </div>

<br />
<br />

 
  <div ID="divtree" runat="server" >
  <div style="border:medium solid #800000; width:38%; float:left; height: 332px;">
  </div>
  <div style="border-style: solid; border-color: #800000; width:62%; height: 334px; margin-top: 0px;">
 
 
        <div id="DropDown" align="right">
             <asp:DropDownList ID="ddlSearchtype" runat="server" Height="20px" Width="205px"
                 AutoPostBack="True"
                 onselectedindexchanged="ddlSearchtype_SelectedIndexChanged" >
                 <asp:ListItem Selected="True" Value="1">View By Region</asp:ListItem>
                 <asp:ListItem Value="2">View By Postal Area</asp:ListItem>
                 <asp:ListItem Value="3">View By Town</asp:ListItem>
             </asp:DropDownList>
        </div>
       <asp:TreeView ID="treeview1" ShowCheckBoxes="All" EnableClientScript="true"
              runat="server"  ShowLines="true" 
            ontreenodecheckchanged="treeview1_TreeNodeCheckChanged"
           onclick="javascript:OnTreeClick()" ontreenodeexpanded="treeview1_TreeNodeExpanded"  Width="481px"
            Height="323px" ShowExpandCollapse="true" >
        </asp:TreeView> <%--__doPostBack() TreeviewExpandCollapseAll('treeview1',true) OnTreeClick()  TreeviewExpandCollapseAll() onselectednodechanged="javascript:OnTreeClick()" ShowExpandCollapse="true"--%>
       
          <a href="javascript:TreeviewExpandCollapseAll('<%=treeview1.ClientID%>', true)">Expand All</a>

  </div>
 
 
  </div>
        <div id="div44" runat="server" style="width: 797px">
    <uc1:searchFooter ID="searchFooter1" runat="server" />
    </div>
   
    </div>
    </ContentTemplate>
</asp:UpdatePanel>
  
    </form>
    </body>
</html>
 

Re: Regarding TextBox
Meetu Choudhary

[quote user="rtpHarry"]This will let you do an autocomplete drop down:

[/quote] 

 

I dont want to use this control i have some my specifications

so i have to  make control accordingly

Re: html page to colorful AJAX page conversion
panky2sharma



 
<embed src="http://fliiby.com/embed/gadget.swf" wmode="transparent" bgcolor="#ffffff" width="360" height="330" allowscriptaccess="always" flashvars="&fileID=96316&fileShort=x9dopi0ndi" />



FileUpload with UpdatePanel
stevecarey

 

Hello,

        I am new to Ajax.net, Does File Upload control works with Updatepanel in AJAX.net

       any idea?

 

 

Re: Calendar control in ASp.net
J K

Hi,
 Is it an Ajax Enabled Website?

Regards,
JK

Re: file upload change file name
ajaykhedekar
Re: Form loses focus after Ajax update
techieanuj

This article might be of some help: 

http://www.codeproject.com/KB/ajax/PageRequestManager.aspx 

Re: Message Box before Page navigation
ajaykhedekar
Re: How to make Div Model
yrajasekhar