KokLim Tan

KokLim Tan

  • NA
  • 19
  • 10.7k

How to change attributes value of user control in div

Feb 11 2016 11:22 AM
<asp:UpdatePanel ID="MachineUpdate" runat="server" UpdateMode="Conditional"> 
      <ContentTemplate> 
         <div id="MachineName" style=""> 
             <uc1:MachineNameControl runat="server" ID="MachineNameControl" commandValue="" /> 
         </div> 
      </ContentTemplate> 
</asp:UpdatePanel>  
My code in MachineNameControl (ascx file)   
public partial class MachineNameControl : System.Web.UI.UserControl     
{          
        public String commandValue { get; set; }          
        protected void Page_Load(object sender, EventArgs e)         
        {             
                    if (!String.IsNullOrEmpty(commandValue))             
                    {                 
                        this.MachineNameDataSource.WhereParameters.Clear();                 
                        this.MachineNameDataSource.AutoGenerateWhereClause = false;                 
                        this.MachineNameDataSource.Where = "it.Head_Id = " +  Convert.ToInt32(commandValue) + " ";             
                       }             
                     else {                 
                     this.MachineNameDataSource.WhereParameters.Clear();                 
                     this.MachineNameDataSource.AutoGenerateWhereClause = false;                 
                     this.MachineNameDataSource.Where = "it.Head_Id > 0  ";             
                     }         
 }

My Problem in client side (I've tried to change attribute value of usercontrol and refresh the updatepanel, 
result is still same and nothing happended)              
         $(function () {                  
                $("#<%= MachineNameControl.ClientID %>").attr("commandValue", "2");                  
                __doPostBack('<%= MachineUpdate.ClientID %>');            
      }
Based on the coding in above, I've tried to change attributes value of '<%= MachineNameControl.ClientID %>' and refresh the content in updatepanel by calling __doPostBack('<%= MachineUpdate.ClientID %>'). Result is same and nothing change to filter record? Can anyone give me a guide, please.Thank!!


Answers (2)