TO HOW: ??? .aspx ????? ?? ????? ???? Visual Basic .NET ??? ??????? ????? ?? ??? ????? ?????? ?????????

???? ?????? ???? ??????
???? ID: 328923 - ?? ???????? ?? ?????? ??? ?? ?? ???? ???? ???? ??.
??? ?? ??????? ???? | ??? ?? ??????? ????

?? ????? ??

??????

?? ??? ?? ??? ???? ????? ???? ?? ?? ???? ???????? ?? ????? ??????? ?? ??????????? ??? ????? ?? HTML ??? ????? ???? ??? ?? ?? ????? ????? ???? ?? .aspx ??? ?? ??? ???? ?? ??? ???? ????? ???????? ?????? ??, ?? ??? ?? ???? Internet Explorer ??? ???????? TreeView ???????? ????? ???? ???

AutoPostBack ???

  • True. ?? AutoPostBack ??? ??, ???????? ?? ??? ???????? ?? ???? ?? ????? ?? ???? ????? ??? ?? postback ???? ???? ?? ??? ????? ?? ??????????? ??? ????? ???

    ?????? ?? ???, AutoPostBack TreeView ???? ???? ?? ??? ??? ???? ???????? ???? ??? postback ?? ??????? ?? ??????????? ???: onExpand; onCollapse; onCheck; ?? onSelectedIndexChange.
  • ???. AutoPostBack False ???? ?? ??? ??????, ?????? ?? ?????? ???? ???????? ??? ?? ???? ??????? ????? ?? ??????????? ????

??? ?????

????? ?????? ???? ?? ??? ???????? ??? ?? onSelectedIndexChange ????? ?? ???????? ???, ????? ????? ?? ???? ?????
  1. ??? ??? ????????? ?????, ?? ?? ????TreeView?? .aspx ??? ??? ????????? ?????
  2. .Aspx ????? ??? ??? ????AutoPostBack?? ???TreeView???? ?? ??? ???????????.
  3. ???????????? ???TreeView, ????? ??????????elipsis (.).. ???, ?? ???? ??? ??? ???? ?? ??? ?????? ?? ????? ?????TreeView?????? ????? ???
  4. ?????onloadHTML ???, ?? ???? ??? ??? ?? ??? ?????initTree?????? ?? ??? ???? ???.. ?? ??????? ???? ?????? ??? ??????? ?? ?????Page_Load????? .aspx ????? ?? ??? ???

    .Aspx ??? ?? HTML ?????, ??? ?????? ?? ??? ??? ??????onload???? ?? ??? ?????body??? ?? ??? ???:
    <body onload="initTree()">
    					
  5. ????? ??? ?? ?? ??? ??????Page_Load???? ?? ??? ???? ?????Page_Load??? ??? ??????? behind???? .aspx ????? ?? ??? ???
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim strTreeName As String = "TreeView1"
        Dim strRef As String = Page.GetPostBackEventReference(TreeView1)
        Dim strScript As String = "<script language=""JavaScript""> " & vbCrLf & _
            "<!-- " & vbCrLf & _
            "	function initTree() { " & vbCrLf & _
            "		" & strTreeName & ".onSelectedIndexChange = function() { " & vbCrLf & _
            "			if (event.oldTreeNodeIndex != event.newTreeNodeIndex) " & vbCrLf & _
            "				this.queueEvent('onselectedindexchange', event.oldTreeNodeIndex & ',' & event.newTreeNodeIndex); " & vbCrLf & _
            "			window.setTimeout('" & strRef.Replace("'", "\'") & "', 0, 'JavaScript'); " & vbCrLf & _
            "		} " & vbCrLf & _
            "	} " & vbCrLf & _
            "// --> " & vbCrLf & _
            "</script>"
    
        Page.RegisterClientScriptBlock("InitTree", strScript)
    End Sub
    					

??? ?? ??????????

??? ???? ?????? ??

The code provided earlier in this article was developed using the following process:
  • An .aspx page was developed andAutoPostBack?? ???TreeViewcontrol was set toTrue.
  • The .aspx page was viewed in the Internet Explorer browser, and the source was saved to an .html file.
  • AutoPostBack?? ???TreeViewcontrol was set to???, and then the page was viewed again in the browser.
  • Comparing the two files and noting the differences helped produce the code provided earlier in this article.

More Information About the Code

  • The code from thePage_Loadfunction in this article renders the following code in the browser:
    <script language="JavaScript">
    <!-- 
        function initTree() { 
            TreeView1.onSelectedIndexChange = function() { 
                if (event.oldTreeNodeIndex != event.newTreeNodeIndex) 
                    this.queueEvent('onselectedindexchange', event.oldTreeNodeIndex & ',' & event.newTreeNodeIndex); 
    
                window.setTimeout('__doPostBack(\'TreeView1\',\'\')', 0, 'JavaScript'); 
            } 
        } 
    // -->
    </script>
    						
    TheinitTreefunction runs when the HTML page is loaded into the browser. TheinitTreefunction overrides theonSelectedIndexChange?? ?????TreeView1so that theonSelectedIndexChangeevent is added to the event queue for the page, and is then posted back to the server.
  • The first line of the newonSelectedIndexChangefunction,
    if (event.oldTreeNodeIndex != event.newTreeNodeIndex) 
        this.queueEvent('onselectedindexchange', event.oldTreeNodeIndex + ',' + event.newTreeNodeIndex);
    						
    is taken directly from the original definition for the function as defined in the saved .html file.
  • ??????AutoPostBackfor the TreeView toTruerenders the following code in HTML:
    window.setTimeout('__doPostBack(\'TreeView1\',\'\')', 0, 'JavaScript');
    						
    Because the postback mechanism (in this case,__doPostBack) ?????? ??? ????????? ?? ???? ??, ????? ??? ?? ????? ?? ????? ?? ?????? ????? ????:
    string strRef = Page.GetPostBackEventReference(TreeView1);
    					
    Postback ????? ?? ?????? ??? ????? ?? ???? ???? ??Page_Load????? ???? ?? ???PostBack??????? ?? ??????

??????

???????? ??????? ?? ???, ????? ???? ???????? ?? ????? ?? ?????? ?? Microsoft ???????? ??? ?????::
305140?????: asp.NET Roadmap

319441TO HOW: ?????? ??? ?? ????? ????? ??? TreeView WebBrowser ???????? ???? ?? ??? Visual Basic .NET ?? ????? ??
Internet Explorer WebControls ??????
(VS.85) http://MSDN.Microsoft.com/en-us/library/ms528669 .aspx

???

???? ID: 328923 - ????? ???????: 04 ?????? 2010 - ??????: 2.0
???? ???? ???? ??:
  • Microsoft ASP.NET 1.0
  • Microsoft Visual Basic .NET 2002 Standard Edition
  • Microsoft ASP.NET 1.1
  • Microsoft Visual Basic .NET 2003 Standard Edition
??????: 
kbhowtomaster kbservercontrols kbmt KB328923 KbMthi
???? ?????? ????????
??????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??.
?????????? ?? ??????? ????????? ??????? ??:328923

??????????? ???

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com