Unable to get text value from user prompt

Kemppaik 21 Reputation points
2023-04-05T13:17:09.41+00:00

I hope someone can help point me in the right direction.  I'm a newbie and have inherited a legacy application and no other employees can help me with this one.

I have an asp.net application that has a Copy button.  When the copy button is pressed, a screen pops-up and users can enter a value to indicate what they want to copy to.  However, the copy does not work.  I can not seem to get the text that the user enters to be picked up in the code so the copy can work.

Why am I unable to get the code to pick up the text that is entered by the user?  I have attached the files and a screenshot showing the copy button feature.

To add to the mystery, users claim this used to work but broke at some point (they don't know when). This application has been in place for over 2 years.

I'd appreciate any guidance/help on this.  As mentioned, I'm a newbie when it comes to this.

Thanks.

Problem described.pdf

Default.aspx.pdf

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,539 questions
0 comments No comments
{count} votes

Accepted answer
  1. Lan Huang-MSFT 29,916 Reputation points Microsoft Vendor
    2023-04-06T03:19:41.4266667+00:00

    Hi @Kemppaik , From what I understand, you want to get the text value from the user prompt. The code you provided is too much (it is best to provide a small example that can reproduce the problem), I only extracted a part of the code according to your needs and tested it. You need to pass prompt value to textbox value not innerText.

     document.getElementById('<%= copyToTB.ClientID %>').value = copyTo;
    

    Here is my test:

    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
         <script>
             function copy() {
                 var copyTo = prompt("Please enter the sales order you want to copy to", "");
                 if (copyTo != null) {
                     document.getElementById('<%= copyToTB.ClientID %>').value = copyTo;
                    document.getElementById('<%= copyButton.ClientID %>').click();
    
                 }
             }
    
         </script>
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" AsyncPostBackTimeout="0">
            <ContentTemplate>
                <asp:TextBox ID="copyToTB" runat="server" CssClass="hidden-field"></asp:TextBox>
                <asp:GridView ID="fileAttachmentGV" runat="server" AutoGenerateColumns="true"
                    CssClass="w3-table-all w3-tiny w3-table-no-border "
                    ShowHeader="false">
                </asp:GridView>
                <span tabindex="-1" class="ms-crm-CommandBar-Button ms-crm-Menu-Label" style="max-width: 200px">
                    <a tabindex="0" class="ms-crm-Menu-Label" onclick="copy();">
                        <img tabindex="-1" class="ms-crm-ImageStrip-Save_16 ms-crm-commandbar-image16by16" style="vertical-align: top" alt="Copy to a new Ticket" src="favicon.ico"></img>
                        <span tabindex="-1" class="ms-crm-CommandBar-Menu" style="max-width: 150px; cursor: pointer;">COPY </span>
                    </a>
                </span>
                <asp:Button ID="copyButton" Style="display: none" runat="server" Text="Copy"
                    OnClick="CopyButton_Click" />
            </ContentTemplate>
            <Triggers>
                <asp:PostBackTrigger ControlID="fileAttachmentGV" />
            </Triggers>
        </asp:UpdatePanel>
    </asp:Content>
    

    15

    Best regards,
    Lan Huang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.