| |

VerySource

 Forgot password?
 Register
Search
View: 1223|Reply: 10

A page is used to display customer information. But this page I think it has both display and editing functions. can

[Copy link]

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-2-20 14:00:01
| Show all posts |Read mode
Dear All,
    I have a problem while doing ASP.NET development. I have a page that is used to display customer information. But this page I think it has both display and editing functions.

    My previous approach was to hide all edited controls (visible = false one by one) when this page is in the "displayed" state, and then assign and display the label controls one by one. There are many lines of code to do these things on each page. (If the page is large)

    I have an idea now, I want to write a function, and then scan all the controls on the page directly, then hide them, and then show their contents in their original position, I can now scan all the controls on the page , But don't know how to proceed to the next step. (For example: it is to hide the TextBox control, and then display the displayed content at the position of the TextBox, and vice versa)

            foreach (Control i in Page.FindControl ("frmEdit"). Controls)
            {
                //Response.Write(i.ID + "---" + i.GetType (). FullName);

            }

    I don't know what I'm saying clearly. Please give instructions.

    Anyway, the main purpose is to be lazy, a page to achieve two functions. :)

Best Regards,

Benny Ng
Reply

Use magic Report

0

Threads

15

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-4-28 09:30:01
| Show all posts
It is said that there is something called Panel
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 Norway

Post time: 2020-4-28 09:45:02
| Show all posts
Frame the edit control with a Table or TD, give the Table or TD a name, id = ***, runat = server, and then hide that Table or TD in the background.

I don't know if I understand it or not!
Reply

Use magic Report

0

Threads

43

Posts

29.00

Credits

Newbie

Rank: 1

Credits
29.00

 Unknown

Post time: 2020-4-28 13:00:01
| Show all posts
Just use panel

Examples:
   ① Conduct user identity check
   ② Fill in the relevant content
   ③ Display the content you filled in


<Html>
 <Body bgcolor = "White">
 <center> <H3> Example of using Panel control <Hr> </ H3> </ center>
<title> Example of using Panel control </ title>
<script Language = "VB" runat = "server">
 Sub Page_Load (sender As Object, e As EventArgs)
    If Not Page.IsPostBack Then
       panel2.Visible = False
       panel3.Visible = False
    End If
 End Sub
Sub Button1_Click (sender As Object, e As EventArgs)
    panel1.Visible = False
    panel2.Visible = True
 End Sub
 
 Sub Button2_Click (sender As Object, e As EventArgs)
    panel2.Visible = False
    panel3.Visible = True
    Span1.InnerHtml = "Username:"&UserID.Text&"<BR>"
    Span1.InnerHtml&= "Password:"&Password.Text&"<BR>"
    Span1.InnerHtml&= "Name:"&Name.Text&"<BR>"
    Span1.InnerHtml&= "Phone:"&Tel.Text&"<BR>"
    Span1.InnerHtml&= "E-mail:"&mail.Text&"<BR>"
    Span1.InnerHtml&= "Address:"&Addr.Text&"<P>"
    
 End Sub
 Sub Button3_Click (sender As Object, e As EventArgs)
    Span1.InnerHtml&= "Input completed!"
    Button3.Visible = False
 End Sub
 </ script>
<Form runat = "server">
<center>
<asp: Panel id = "panel1" runat = "server">
 <Font Color = "# 800000"> <B> Step 1: Please enter your username and password </ B> </ Font> <Blockquote>
      Username: <asp: TextBox id = "UserID" runat = "server" Text = "kjwang" /> <p>
        Password: <asp: TextBox id = "Password" TextMode = "Password"
             Text = "kj6688" runat = "server" /> <p>
       <Input Type = "Button" id = "Button1" value = "Login"
              OnServerClick = "Button1_Click" runat = "server">
 </ Blockquote>
 </ asp: Panel>
 <asp: Panel id = "panel2" runat = "server">
 <Font Color = "# 800000"> <B> Step 2: Please enter user information </ B> </ Font> <Blockquote>
       Name: <asp: TextBox id = "Name" runat = "server" Text = "小李" /> <p>
       Phone: <asp: TextBox id = "Tel" runat = "server" Text = "(023) 65355678" /> <p>
       E-mail: <asp: TextBox id = "mail" runat = "server" Text = "jimmy.zh@263.net" /> <p>
       Address: <asp: TextBox id = "Addr" runat = "server" Text = "Chongqing Renmin Road 115 #" Size = "40" /> <p>
       <Input Type = "Button" id = "Button2" value = "Apply"
              OnServerClick = "Button2_Click" runat = "server">
 </ Blockquote>
 </ asp: Panel>
  <asp: Panel id = "panel3" runat = "server">
 <Font Color = "# 800000"> <B> Step 3: Please confirm your input </ B> </ Font> <Blockquote>
    <Span id = "Span1" runat = "server" />
    <Input Type = "Button" id = "Button3" value = "Confirm"
           OnServerClick = "Button3_Click" runat = "server">
 </ Blockquote>
 </ asp: Panel>
</ center>
 </ form>
 <Hr> </ body>
 </ html>
Reply

Use magic Report

0

Threads

8

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-4-29 12:45:01
| Show all posts
Put the things to be displayed or hidden directly into the PANNEL, and then set the visible property of only one PANNEL
Reply

Use magic Report

0

Threads

17

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-4-29 19:00:01
| Show all posts
panel can
Reply

Use magic Report

0

Threads

7

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-4-30 19:45:01
| Show all posts
CSS is more convenient
The form for editing is hidden first, put an edit button, click to display the edit form, use CSS to achieve no refresh, and save server resources
Reply

Use magic Report

0

Threads

7

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-5-1 11:00:01
| Show all posts
Maybe I misunderstood the meaning of the landlord.Does the landlord want to edit the content first? After the submission, the edited content is displayed on the same page for people to confirm?
If that's the case, you can use the panel better
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-5-28 09:30:01
| Show all posts
In fact, I want to use a page, such as abc.aspx. In it, if I pass the parameter? Action = edit. This page becomes the editing page. What if I pass the parameter? Action = view? It becomes the displayed page.

Now I deploy two elements for each FIELD, one for editing and one for display, which are hidden / displayed in different situations. So it will be more troublesome. (Because there are a lot of boring code to write, such as control1.visible = true, control2.visible = false. Etc.)

So I just want to know a thought to achieve this need only ~:) ~~
Reply

Use magic Report

0

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-6-12 00:00:01
| Show all posts
My general approach is:
1. Write two panels, one visible=true and the other false
2. Set the readonly attribute of all textboxes
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