|
where is the code in this message?
|
|
|
|
|
|
Hi,
i have one multi line text box and one save button..
When a SAVE button is pressed it will perform a action on the
database either to add data that a user has entered.
When the refresh button is pressed at the top of the page the same
exact data is re-submitted again resulting duplicate transaction in the
database. Is there anyway of stopping this happening? From client-side
script or server side , how can we detect that the "Refresh" button is click?
|
|
|
|
|
The most likely cause of this scenario is not handling Page.IsPostBack properly. Where is the logic for the save button? I know the language. I've read a book. - _Madmatt
|
|
|
|
|
after iam saving data in to database..
when we click on page refresh button ,its again stored in database..
|
|
|
|
|
Yes, you explained that in the first post.
Where is the logic for save action? Are you checking IsPostBack? I know the language. I've read a book. - _Madmatt
|
|
|
|
|
|
You are not getting it. You are obviously not handling it properly or it would not be happening. Show what you have done so we may be able to point out your mistake. I know the language. I've read a book. - _Madmatt
|
|
|
|
|
IsPostBack can't tell the difference between clicking a button and clicking refresh since refresh posts all the same stuff to the server as the previous POST from the button click.
|
|
|
|
|
Yes, however the OP stated they were clicking a refresh button. It should be easily handled in the button click events unless the logic for the submit action is being done in the page load event. I know the language. I've read a book. - _Madmatt
|
|
|
|
|
You don't get a click event for the IE browser refresh button.
|
|
|
|
|
You do with a button. The OP said they clicking a refresh button. I assumed another button on the page, not the browser refresh
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
The one solution I can think of is after saving information in database, redirect the page to another page, which, in turns redirects back to the previous page...
I mean, you can do this:
1. Save data in database
2. Redirect to another page, say temp.aspx
3. On temp.aspx, write code to redirect back to the previous page
In this way, after saving the information user will always get a new instance of the same page. Being a new page, hitting refresh button will not again post back the page.
|
|
|
|
|
When you know for sure that the users are bound to click the browser's refresh button to refresh the screen, why not put a refresh button on screen along side the data that they expect to be updated and perform a refresh of just that data?
That was just a suggestion to improve your application. Now to the solution to your problem.
Once the save is completed, just register a client script that would make a fresh request for the page. You can do so by calling window.location.reload() or window.location.url='PageName.aspx';
This would refresh the page and the next time Refresh/F5 is hit only page load is posted not the button click.
NOTE: Register either of these scripts from the server after the button click, don't directly add it on the existing javascript blocks.
HTH!!!
|
|
|
|
|
This is the best approach. I do agree with you Dinesh.
There is no foolish question, there is no final answer...
|
|
|
|
|
One simple solution is Redirect to the same page after submitting the data. ie, in the submit button click use,
Response.Redirect(samepage)
|
|
|
|
|
Hi,
we are developing an application in ASP .NET. Every connected client is downloading a small file (about 12kb) every second. This file is changed every second by a multithreaded application.
We have dedicated server for this solution, but it performs really bad when there are about 100 clients connected.
My questions is: could this performance problem be caused by downloading this small file so often?
Thank you for your answer.
|
|
|
|
|
|
Does the file change each time or could you only download as required? Does it need to be every second? Does every client really need it that often?me, me, me
"The dinosaurs became extinct because they didn't have a space program. And if we become extinct because we don't have a space program, it'll serve us right!"
Larry Niven
|
|
|
|
|
Yes, it does change every second, and it is a business requirement that the client has to be notified of the change.
|
|
|
|
|
Hi, the requirement looks easily but i am not knowing how to achieve this.
i have two strings as below
string _mainstr = "INDI,GERM,ENGL,SCOT,BLAC,BANG,CHIN,JAPN";
string _substr = "CHIN,ENGL,INDI";
Now i want to remove all other country names from _mainstr which are not in _substr. But the order shouldn't be changed.
I am looking an ouput from _mainstr as follows
_mainstr = "INDI,ENGL,CHIN";
Here the order is important.
How can i get this in c#? Please give an ideaG. Satish
modified on Thursday, March 18, 2010 5:50 AM
|
|
|
|
|
First create function in database(for split these val;ues)
CREATE FUNCTION [dbo].[Split](@String varchar(8000), @Delimiter char(1))
returns @temptable TABLE (i int identity(1,1), items varchar(8000))
as
begin
declare @idx int
declare @slice varchar(8000)
select @idx = 1
if len(@String)<1 or @String is null return
while @idx!= 0
begin
set @idx = charindex(@Delimiter,@String)
if @idx!=0
set @slice = left(@String,@idx - 1)
else
set @slice = @String
if(len(@slice)>0)
insert into @temptable(Items) values(@slice)
set @String = right(@String,len(@String) - @idx)
if len(@String) = 0 break
end
return
after that create sp(that should be like that )
create storedprocedure [dbo].[sp_notINMain]
@_mainstr navrchar(1000),
@_substr nvarchra(1000)
begin
as
select a.items , b.items from dbo.split(@_mainstr,',') a inner join
dbo.split(@_substr,',') b on a.i = b.i where a.items not in(b.items) order by a.i asc
end
Try This may HELP......
|
|
|
|
|
Thanks for ur funcion. But its not meeting my criteria..it giving some wrong results. G. Satish
|
|
|
|
|
Satish - Developer wrote: How can i get this in c#?
This is not C# I know the language. I've read a book. - _Madmatt
|
|
|
|
|
use .Split off substr to create an array of searched for strings.
Iterate through this against _mainstr.
With a stringbuilder, if you've got a match, append this to a holding object.
At the end of it your stringbuilder will have the matched strings in the right order.
|
|
|
|