Unable to change label text for certain location on web form (Label.text = "string")

Discussion in 'C#' started by hkw_9105, Dec 7, 2012.

  1. hkw_9105

    hkw_9105 New Member

    Joined:
    Aug 18, 2010
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Hi,

    I am trying to change label text on button click, the way label.text = "string" work well before but not in this case.
    I tried to put this on other method and it work..it is just not working on the button that I would like to fire..

    Can anybody help?? I stuck in this problem for fews day..and cant get any useful information from google..

    C# code :
    Code:
    protected void btnTotalGroupMember_Click(object sender, EventArgs e)
    {
    string s = "there";
    string[] words = s.Split(' ');
    foreach (string word in words)
    {
    Label1.Text = s;
    }
    
    SqlConnection con;
    String conStr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
    con = new SqlConnection(conStr);
    
    con.Open();
    
    string selectMemberQuery = "SELECT userID from [group]";
    SqlCommand cmd = new SqlCommand(selectMemberQuery, con);
    SqlDataReader rd = cmd.ExecuteReader();
    
    if (rd.HasRows)
    {
    rd.Read();
    
    string UID = rd["userID"].ToString();
    string[] cUIDs = UID.Split(',');
    foreach (string cUID in cUIDs)
    {
    string sqlQuery2 = "SELECT m.username,m.email from member m,group g where m.userID = " + cUID;
    SqlCommand cmd2 = new SqlCommand(sqlQuery2, con);
    SqlDataReader rd2 = cmd2.ExecuteReader();
    
    /* if (rd2.HasRows)
    {
    rd2.Read();
    
    
    Table tbl = new Table();
    tbl.ID = "tblUser";
    
    this.Controls.Add(tbl);
    
    TableRow rw = new TableRow();
    
    TableCell cell = new TableCell();
    TableCell cell2 = new TableCell();
    
    Label text = new Label();
    Label text2 = new Label();
    
    Label1.Text = rd2["username"].ToString();
    Label2.Text = rd2["email"].ToString();
    
    cell.Controls.Add(text);
    cell2.Controls.Add(text2);
    
    rw.Cells.Add(cell);
    rw.Cells.Add(cell2);
    
    tbl.Controls.Add(rw);
    }*/
    }
    
    }
    
    con.Close();
    
    }

    Web Form ( button)

    Code:
    <asp:Button ID="btnTotalGroupMember" runat="server" 
    BorderStyle="None" Font-Size="12px" ForeColor="#A29881" BackColor="White" 
    OnClientClick="return addEventInterface2();" 
    onclick="btnTotalGroupMember_Click"/>
    Web Form (addEventInterface2) -> Java script function
    Code:
    function addEventInterface2() {
    document.getElementById('overlayLayer2').style.paddingTop = "50%";
    document.getElementById('overlayLayer2').style.visibility = "visible";
    document.getElementById('overlayLayer2').className = "ui-widget-overlay";
    document.getElementById('shadow2').className = "ui-widget-shadow ui-corner-all";
    document.getElementById('shadow2').style.visibility = "visible";
    document.getElementById('hi3').className = "ui-widget ui-widget-content ui-corner-all";
    document.getElementById('hi3').style.visibility = "visible";
    document.getElementById('addEventIntContent2').className = "ui-dialog-content ui-widget-content";
    document.getElementById('addEventIntContent2').style.visibility = "visible";
    document.getElementById('draggableInt2').style.visibility = "visible";
    return false;
    }
    Web form ( the location of label text that I would like to change)

    Code:
    <div id="overlayLayer2" style="height: 1%; visibility: hidden;"> 
    </div>
    <div id="draggableInt2" style="width: 50%; height: 65%; position: absolute; left: 32%; top: 20%;
    visibility: hidden;">
    <div id="shadow2" style="width: 100%; height: 100%; position: absolute; left: 0.5%;
    top: 0.5%; visibility: hidden;">
    </div>
    <div id="hi3" style="position: absolute; width: 97%; height: 97%; left: 1.5%; top: 1.5%;
    visibility: hidden;">
    <div id="addEventIntContent2" style="background: none; border: 0; visibility: hidden;">
    <br />
    <div style="float: right">
    <asp:ImageButton ID="btnCloseEventInt2" runat="server" ImageUrl="~/image/btnCloseEventInt.png"
    OnClientClick="return endEventInterface2()" />
    </div>
    <div>
    <asp:Label ID="Label1" runat="server" ></asp:Label>
    <asp:Label ID="Label2" runat="server" ></asp:Label>
    </div> 
    </div>
    </div>
    </div>
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice