Skip to content

How to change attributes value of user control in div

KokLim Tan

Asked Feb 11, 2016, 6:22 AM EST2 answers
Share
LinkedInX
Code
<asp:UpdatePanel ID="MachineUpdate" runat="server" UpdateMode="Conditional">
Code
      <ContentTemplate>
Code
         <div id="MachineName" style="">
Code
             <uc1:MachineNameControl runat="server" ID="MachineNameControl" commandValue="" />
Code
         </div>
Code
      </ContentTemplate>
Code
</asp:UpdatePanel>
Code
My code in MachineNameControl (ascx file)
Code
public partial class MachineNameControl : System.Web.UI.UserControl
Code
{
Code
        public String commandValue { get; set; }
Code
        protected void Page_Load(object sender, EventArgs e)
Code
        {
Code
                    if (!String.IsNullOrEmpty(commandValue))
Code
                    {
Code
                        this.MachineNameDataSource.WhereParameters.Clear();
Code
                        this.MachineNameDataSource.AutoGenerateWhereClause = false;
Code
                        this.MachineNameDataSource.Where = "it.Head_Id = " +  Convert.ToInt32(commandValue) + " ";
Code
                       }
Code
                     else {
Code
                     this.MachineNameDataSource.WhereParameters.Clear();
Code
                     this.MachineNameDataSource.AutoGenerateWhereClause = false;
Code
                     this.MachineNameDataSource.Where = "it.Head_Id > 0  ";
Code
                     }
Code
       }
Code
 }
Code
Code
My Problem in client side (I've tried to change attribute value of usercontrol and refresh the updatepanel,
Code
result is still same and nothing happended)
Code
         $(function () {
Code
                $("#<%= MachineNameControl.ClientID %>").attr("commandValue", "2");
Code
                __doPostBack('<%= MachineUpdate.ClientID %>');
Code
      }
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!!

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.