Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to change attributes value of user control in div

Status
Not open for further replies.

koklimabc

Programmer
Jun 17, 2013
49
MY
Code:
<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!!
 
You will not be able to set a server object's property through client side script.
Using the .prop() or .attr() only affects the dom object (what html is renders) not the value of an actual property.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top