Answered Submit functionality in a visual web part

  • 13 มีนาคม 2555 16:36
     
     

    I have created a visual web part to collect user feedback and save it to a list in sharepoint.

    And I display user comments based on if the user clicks on the submit button without any content.

    I want to be able to get rid of these comments say in about 10 seconds or so from the page, from the time of display.

    How can I achieve this?

    Refer code below.

    protected void Button_Click(object sender, EventArgs e)
            {
                if (TextBox.Text.Length == 0)
                    Label2.Text = "Please enter a suggestion before submitting";
                else
                {

                    Label2.Text = "Thank you for your suggestion!";
                    TextBox.Text = "";

                }

    }

ตอบทั้งหมด

  • 13 มีนาคม 2555 16:44
     
     
    You could just use a ToolTip on the Textboxes that require content. Might a cleaner way to go about this.
  • 13 มีนาคม 2555 16:51
     
     

    Beau Cameron

    I do have tool tips for the text box and the submit button.

    But when users submit somefeedback i'd like to display "Thank you for the feedback" and then make this go away in about 10seconds.

    is there like a wait() or a timer () function that I could use to delay the command label.text=string.empty; ?

  • 13 มีนาคม 2555 17:33
     
     คำตอบ

    You can use Client Object Model for that. The combination of SP.UI.Notify.addNotification http://msdn.microsoft.com/en-us/library/ee658473.aspx and executeOrDelayUntilScriptLoaded http://msdn.microsoft.com/en-us/library/ff411788.aspx that is exactly what you need.


    Oleg

  • 13 มีนาคม 2555 17:43
     
     คำตอบ

    hi,


            i am thinking that rather than checking textbox character length from server side,you can write javascript validation. if it is comments text box character length is zero,show your message and then start javascript timer jobs inside the timer you can control ur message display activites.Please check below link how to apply the timer

    http://www.w3schools.com/js/js_timing.asp

    for writing the client side javscript in your submit in the onclientclick property.Please check below link

    http://www.c-sharpcorner.com/UploadFile/purankaushal/103222006013805AM/1.aspx

    • ทำเครื่องหมายเป็นคำตอบโดย Qiao WeiMicrosoft, Moderator 26 มีนาคม 2555 10:03
    •