ASTreeView – How to disable checkbox PostBack

by Weijie JIN on

There’s a request that to disable the checkbox PostBack while the AutoPostBack properties is set to true. Because for node selection, we want to enable the PostBack.

By default, if we set the AutoPostBack properties of ASTreeView, both the checkbox and selection will be effected.

So here we need a little tricky to achieve that:

First, in the aspx page, we need to remove the postback related attribute for the checkbox, here’s the javascript function you can put into your aspx page:

<script type="text/javascript">
	function clearCheckboxPostBackEvent(){
		var cbs = document.getElementsByTagName("IMG");
		for( var i = 0; i < cbs.length; i++ )
			if( cbs[i].className == "astreeview-checkbox" ){

Then, in the code behind, in Page_Load event handler, you call the javascript function above:

protected void Page_Load( object sender, EventArgs e )
	string clearCheckboxPostbackScript = "clearCheckboxPostBackEvent();";
	ScriptManager sm = ScriptManager.GetCurrent( this );
	if( sm != null && sm.EnablePartialRendering )
		ScriptManager.RegisterStartupScript( this
										, this.GetType()
										, "clearCBPostback"
										, clearCheckboxPostbackScript
										, true );
		ClientScript.RegisterStartupScript( this.GetType()
										, "clearCBPostback"
										, clearCheckboxPostbackScript
										, true );


That’s it, the result will be: the selection postback is activated and the checkbox won’t perform postback by clicking.

  • xiaoyq



  • jinweijie



  • wp


  • jinweijie


  • catman

    XML 数据源方式,不能在数据源中添加自己定义的属性,否则绑定的时候会出错:
    The ‘code’ attribute is not declared.
    而这是很必要的,因为需要根据这个属性来搜索 XML 节点,以便添加后续的 XML 节点,现在的做法我只能是先添加自己定义的属性,然后在绑定之前再把这些属性删除。

    另外,XML 数据源格式,不知道为什么要加一个 ,直接后面跟 节点不是更方便吗?

  • jinweijie


  • Ajay

    have a simple question. how do we set a checkbox state from client side javascript? I tried the setAttribute method, but the checkbox was unchanged. Can you please help?

  • jinweijie

    Hi, could you please submit your requests to mantis? all the request will be queued. you can find the link here:


  • Kayce Warneka

    I value the effort you’ve taken to post. Continue the very good work.

Previous post:

Next post: