Write a program to create a user control with name and surname as data members and login as method and also the code to call it. (Hint use event delegates) Practical Example of Passing an Events to delegates
Answer / Pawan Kumar Verma
"Creating a UserControl in C# involves defining a class that inherits from System.Web.UI.UserControl, and defining properties for your data members such as Name and Surname. Here is an example:nn```csharpnpublic partial class MyUserControl : System.Web.UI.UserControl {n public string Name {n get {n return (string)ViewState["Name"];n }n set {n ViewState["Name"] = value;n }n }n public string Surname {n get {n return (string)ViewState["Surname"];n }n set {n ViewState["Surname"] = value;n }n }n protected void Page_Load(object sender, EventArgs e) {n // Initialize controls heren }n public event EventHandler LoginEvent;n protected void Button1_Click(object sender, EventArgs e) {n if (ValidateLogin()) {n OnLogin();n }n }n private bool ValidateLogin() {n // Validation logic heren return true; // Replace with actual validationn }n protected virtual void OnLogin() {n if (LoginEvent != null) {n LoginEvent(this, EventArgs.Empty);n }n }n}"
| Is This Answer Correct ? | 0 Yes | 0 No |
What's the difference between a method and a procedure?
What is c# best for?
What is short circuit logical evaluation?
What is the use of jit ? Jit (just - in - time) is a compiler which converts msil code to
What is multiple interface in c#?
How do I run managed code in a process?
public void A() { int x; x = 8; x *= 4 + 8 / 2; } Given the above code, what is the value of "x"?
Can hashtable have duplicate keys in c#?
Can we write one page in c# and other in vb in one application ?
What is window application in c#?
Why do we use struct in c#?
What are satellite assemblies? How will you get the different language strings?
Visual Basic (800)
C Sharp (3816)
ASP.NET (3180)
VB.NET (461)
COM+ (79)
ADO.NET (717)
IIS (369)
MTS (11)
Crystal Reports (81)
BizTalk (89)
Dot Net (2435)
Exchange Server (362)
SharePoint (720)
WCF (340)
MS Office Microsoft (6963)
LINQ Language-Integrated Query (317)
WPF (371)
TypeScript (144)
Microsoft Related AllOther (311)