aspnet confirmation from Client

  • Thread starter Thread starter sweetpotatop
  • Start date Start date
S

sweetpotatop

Hi,

I have a page written in C# asp.net, which allow users to select and
delete records.

Once user selects the record to be deleted, I will confirm with the
user, something like "Are you sure you want to delete the selected
records?"

If yes, I will go and delete the record from SQL. How can this
confirmation and deleting process be done?
From what I understand, I need javascript to confirm with the user,
but then how can I transfer the response back to the server and delete
those selected records from the server?

Thanks in advance. Your advice and help would be greatly appreciated.
 
I have a page written in C# asp.net, which allow users to select and
delete records.

How are the records presented to the user?
Once user selects the record to be deleted, I will confirm with the
user, something like "Are you sure you want to delete the selected
records?"

If yes, I will go and delete the record from SQL. How can this
confirmation and deleting process be done?

<asp:Button ID="MyButton" runat="server" Text="Delete"
OnClick="MyButton_Click" OnClientClick="return confirm('Are you sure you
want to delete this record?');" />
but then how can I transfer the response back to the server and delete
those selected records from the server?

That's what a postback is for... When the user clicks the above button, a
JavaScript alert will ask them to confirm that they want to continue. If
they don't, nothing further will happen. If they do, the server-side
MyButton_Click event will fire - that's where you write the code to delete
the record...
 
How are the records presented to the user?



<asp:Button ID="MyButton" runat="server" Text="Delete"
OnClick="MyButton_Click" OnClientClick="return confirm('Are you sure you
want to delete this record?');" />


That's what a postback is for... When the user clicks the above button, a
JavaScript alert will ask them to confirm that they want to continue. If
they don't, nothing further will happen. If they do, the server-side
MyButton_Click event will fire - that's where you write the code to delete
the record...

The button is setup in the way that you described above. But how do I
get the return value from the server side? What variable does the
return value go?
 
The button is setup in the way that you described above. But how do I
get the return value from the server side? What variable does the
return value go?

What return value are you talking about...?
 
What return value are you talking about...?

Return value is the actual response from the user, e.g "Yes" to
delete , or "No" (client-side respond)

Since I am going to delete the record from the server-side, is there a
server-side variable that capture the respond from the user (client-
side)?
 
Return value is the actual response from the user, e.g "Yes" to
delete , or "No" (client-side respond)

OnClientClick="return confirm('Are you sure...?');

Note the word "return" before "confirm"...
Since I am going to delete the record from the server-side, is there a
server-side variable that capture the respond from the user (client-
side)?

None is needed - if the user chooses not to continue, the postback doesn't
happen...
 
Back
Top