It's quite difficult at noon, so listen to songs and record the morning stuff.
On the page where the file was uploaded yesterday, you need to record some information while uploading the file. After uploading the file, you need to clear the entered content. (Textbox is used)
In fact, this can be processed using JavaScript. In addition, on the client side, the pressure on the server is reduced. As an exercise, I chose to process it on the server.
Traverse all the controls on the page and judge whether it is actually not a textbox. If yes, the value is null.
Private void clear ()
{
Foreach (Control in this. findcontrol ("form1"). Controls)
{
If (control is textbox)
{
(Textbox) control). Text = string. empty;
// Clear (control. Controls );
}
}
}
This idea is the easiest to think of. Of course, when I look at similar problems on the internet, I find that reflection can also be used to solve the problem. Although for a simple traversal, the efficiency of using reflection may not be high, but for the purpose of learning, try learning ~ I was just reading a series of reflection articles from Ziyang recently.
Private void clear2 ()
{
Type T = typeof (textbox );
Fieldinfo [] Infos = This. GetType (). getfields (bindingflags. getfield | bindingflags. Public | bindingflags. nonpublic | bindingflags. instance );
For (INT I = 0; I <Infos. length; I ++)
{
If (Infos [I]. fieldtype. Name = T. Name)
{
(Textbox) Infos [I]. getvalue (this). Text = string. empty;
}
}
}
First, obtain the textbox type, then obtain the type in the current instance, use the binding constraint, search for the field currently defined by system. type, and store it in the Infos array.
Then, the system goes to the traversal array and determines whether it is a textbox type. If yes, the value is changed. This is just a matter of ignorance and remains to be studied.
The function is implemented, not completely mastered