Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.7k views
in Technique[技术] by (71.8m points)

c# - How to show "success" message on submit?

Using C# with ASP.NET, how do I show a "success" message when my user submits a form? And at the same time say "The image has successfully saved", with a link, so that the image created can be viewed by clicking the link?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Wrap your form in an <asp:Panel> and create another <asp:Panel> with Visible="False" for your Thank you message. Once the form is submitted, change the visibility of each panel, setting the form to Visible="False", and the thank you message panel to Visible="True".

Hope that makes sense, here's an example:

<asp:Panel ID="pnlFormFields" runat="server">
    ... form fields here ...
</asp:Panel>

<asp:Panel ID="pnlThankYouMessage" runat="server" Visible="False">
    ... Thank you message here ...
</asp:Panel>

Then inside your codebehind

protected void btnSubmit_Click(object sender, EventArgs e) {
    // Hook up uploaded image and assign link to it
    pnlFormFields.Visible = false;
    pnlThankYouMessage.Visible = true;
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...