Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Get and Set Data to User Control

Posted on 2005-03-01
6
Medium Priority
?
178 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
  • 2
3 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

571 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