C#

Moderators: None (Apply to moderate this forum)
Number of threads: 2720
Number of posts: 5746

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Unable to change label text for certain location on web form (Label.te Posted by hkw_9105 on 7 Dec 2012 at 2:05 AM
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 :
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)

<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

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)

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




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.