| |

VerySource

 Forgot password?
 Register
Search
View: 677|Reply: 3

How to get the value of a custom control in an ASP form?

[Copy link]

2

Threads

6

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-1-24 19:40:02
| Show all posts |Read mode
For example: There is a text tb in the custom control xinxi.ascx, how to get the input value of tb in the form
Reply

Use magic Report

0

Threads

322

Posts

115.00

Credits

Newbie

Rank: 1

Credits
115.00

 China

Post time: 2020-2-12 11:00:01
| Show all posts
Set a property in xinxi.ascx

Such as:

public tbText
{
 get
 {
    return this.tb.Text;
 }
}

Access the control.tbText in aspx.
Reply

Use magic Report

0

Threads

41

Posts

13.00

Credits

Newbie

Rank: 1

Credits
13.00

 China

Post time: 2020-2-14 17:15:01
| Show all posts
Suppose xinxi1 is an instance of xinxi

TextBox tb = xinxi1.FindControl ("tb") as TextBox;
if (tb! = null)
{
  string a = tb.Text;
}
Reply

Use magic Report

0

Threads

11

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-2-17 19:45:02
| Show all posts
There is a text tb in xinxi.ascx
string a = this.tb.text.tostring ();
a is the value you want to get
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list