Click here to Skip to main content
15,891,923 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Sir
I have a Customer application Page which has more then 40 data going to database. But When I press two times to the save button , it is going twice to the database. I have written submit.Enable=False also but due to net slow if the client click twice then it is going twice to the database.

Is there any solution then when I click the button then the page will halt some time till data will insert to the database.

Please Help Me.

Thanks.
Posted
Comments
srilekhamenon 28-Jan-12 6:23am    
clear the fields after saving data

Hi JBSahu,

Why Don't you use the Progress Bar, I this case you only have to write code at Button Click Event
C#
System.Threading.Thread.Sleep(5000);


Here This code will help your button stop for a while until value not saved in database
but the condition will be invisible,
for this you need to use an "image of please wait" this will show client to stop for a while you can also inrease time 5000 is the time in bracket and remeber it should be in thousand only least one you can give 1000 don;t go less than it.

If you would like to show this with an image use Update Panel and Update Progress

In Update declare your Image and call Id of Progress in Update Panel and also you can make css to fix the size of an image.

Coupled With, Use Proper validations to stop the above problems that client facing, use of Validation group in Validation properties.

Like for example:-

<asp:button id="btSubmit" runat="Server" text="Submit" validationgroup="Submit" />

<asp:requiredfieldvalidator id="RFV_btn" runat="Server" validationgroup="Submit" controltovalidate="yourfieldId" setfocusonerror="True" errormessage="Fill Entries First" ></asp:requiredfieldvalidator>

Like RequiredFieldValidator ValidationGroup Property Exist in other validation also. Use and Then Tell.
 
Share this answer
 
v2
Comments
JBSAHU 28-Jan-12 3:51am    
Thanks Sir,

can you give me one example actually I have never use progress bar and Threading in my project but I know the concept. If possible then please help me.
you can make button visible false on click by JS
like onclick
button.style.display=none;
 
Share this answer
 
Hi JBSahu,

(I am giving only examples alter it as you requirement)

As You asked me about,how to use progress bar, please follow below steps one by one:

1)make a folder, When You will Right click on solution explorer New Folder option will come Take that folder and name as "Image Folder".

2)save one Image of Please wait inside that folder

3)put css shown below:-

<style type="text/css"><br />
.progress<br />
        {<br />
         height:58px;<br />
         width:72px;<br />
         background-image:url('images/progress.gif');<br />
<br />
        }<br />
<br />
</style>


4).Take update panel and Update Progress

see code below:-

XML
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
         <ProgressTemplate>
          <div class="progress">
         <img src="Images/progress.gif" />

          </div>
       </ProgressTemplate>
            </asp:UpdateProgress>


and

Update Panel

XML
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:Button ID="btnshowReport" runat="server" onclick="btnshowReport_Click"
                    Text="ShowReport" CommandName="EDIT"  />
</ContentTemplate>
</asp:UpdatePanel>


Put your button inside the update panel at its click event write this code
C#
System.Threading.Thread.Sleep(5000);


and then tell me it is working or not
 
Share this answer
 
Comments
JBSAHU 28-Jan-12 6:27am    
Thank You so much

But I can click my button at the time thread sleep. When the image is running my button should be background of the image by which i could not click it again till processing.

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