Click here to Skip to main content
15,905,558 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am Sending an Email from Asp.net application by clicking on a Submit button. I used an Image for Loading when sending an Email, and after sending it shows 'Email Sent Successfully'. Another button (Reset) is for Clearing all the textbox fields. When I am click the submit button it is showing the image Loading correctly but also it is showing the Reset button and the loading image

HTML
<asp:ScriptManager ID="scriptmanager" runat="server"></asp:ScriptManager>
    <script language="javascript" type="text/javascript">
        // Get the instance of PageRequestManager.
        var prm = Sys.WebForms.PageRequestManager.getInstance();
        // Add initializeRequest and endRequest
        prm.add_initializeRequest(prm_InitializeRequest);
        prm.add_endRequest(prm_EndRequest);
        // Called when async postback begins
        function prm_InitializeRequest(sender, args) {
            // get the divImage and set it to visible
            var panelProg = $get('divImage');
            panelProg.style.display = '';
            // reset label text
            var lbl = $get('<%= this.lblStatus.ClientID %>');
            lbl.innerHTML = '';
            // Disable button that caused a postback
            $get(args._postBackElement.id).disabled = true;
        }
        // Called when async postback ends
        function prm_EndRequest(sender, args) {
            // get the divImage and hide it again
            var panelProg = $get('divImage');
            panelProg.style.display = 'none';
            // Enable button that caused a postback
            $get(sender._postBackSettings.sourceElement.id).disabled = false;
        }
         </script>

<tr><td align="center">
               <asp:Button ID="btnsubmit" runat="server" Text="Submit" CssClass="buttons"
                        onclick="btnsubmit_Click" CausesValidation="true" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
               <asp:Button ID="btnreset" runat="server" Text="Reset" CssClass="buttons" CausesValidation="false"
                        onclick="btnreset_Click" />
               </td>
               <td>
               </td>
               </tr>
               <tr><td>
               <asp:Label ID="lblStatus" runat="server" ForeColor="Red"></asp:Label>
              <div id="divImage" style="display:none">
                    <asp:Image ID="img1" runat="server" ImageUrl="~/images/progress.gif" />
                    Sending...
               </div>



Here My Problem is I am getting the Sending Image also for Reset Button
how can i show it only for the submit button
Posted
Updated 2-Feb-11 0:27am
v3
Comments
sapien4u 2-Feb-11 6:45am    
Please share the CSS styles also. It may be an issue with the CSS.
NewtoSharepoint 2-Feb-11 7:01am    
No i didn't use css for this

1 solution

Hi,

You use javascript for pagerequestmanager is apply for both button event. So in prm_InitializeRequest check button click event. And put a condition when reset button come than code not fire.
 
Share this answer
 
Comments
NewtoSharepoint 2-Feb-11 7:52am    
Thanks your suggestion helped me

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900