?
Solved

Get and Set Data to User Control

Posted on 2005-03-01
6
Medium Priority
?
172 Views
Last Modified: 2012-08-13
Hi,

How can I use "C# Behind codes" to set a label in User Control?
And how to retrieve the text of the label in the User Control?

0
Comment
Question by:truptivarma
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
6 Comments
 
LVL 5

Expert Comment

by:aspmaestro
ID: 13428030
code for user control (mycontrol.ascx):
------------------------------------------------

<script language="C#" runat="server">
public String UserId {
   get {
      return User.Text;
   }
   set {
      User.Text = value;
   }
}


</script>

<table>
<tr>
   <td><b>Message: </b></td>
   <td><ASP:Label id="User" runat="server"/></td></tr>

</table>

-----------------------------
using the above control in web form:

<%@ Register tagPrefix="myCtrls" tagName="uclabel" src="myControl.ascx" %>

<form runat="server">
      <myCtrls:uclabel id="myLbl" runat="server"/>
</form>


you can refer to the user control as:
myLbl.UserId="testing"
(set the text)
response.write (myLbl.UserId);
(get the text)
0
 

Author Comment

by:truptivarma
ID: 13435357
Thanks but that is from the webform.aspx.

i need to set and retrieve the datas from webform.aspx.cs
0
 
LVL 5

Accepted Solution

by:
aspmaestro earned 2000 total points
ID: 13436062
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question