×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

How to change attributes value of user control in div

How to change attributes value of user control in div

How to change attributes value of user control in div

(OP)

CODE --> C#

<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!!

RE: How to change attributes value of user control in div

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.

RE: How to change attributes value of user control in div

(OP)
Thanks.....

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close