I am a newbie with web programming. I have this problem:
- The user see a page and click on "Upload document".
- The document is uploaded on the server, is read, and the page shows the new informations learned from the file.
- The user can click on a "PERFORM" button. This call a server method.
- In the server method there is a if statement. If this is true, is
all okay.. Else, a confirm dialog in showed to the user.
- if the user choose NO, the process ends.
- if the user choose YES, another different server method is executed, and after this the point (d) is repeated again.
The poin 1, 2 and 3 are done. I have difficult with the 4th point...
I think because I have not yet entirely clear how to interact with servers and clients together. I know that you can not directly call JavaScript from C# and viceversa, but there are several techniques (like Ajax) to do it ... but these are not yet clear to me.
This is an example of my code:
UploadDoc.aspx
<script type="text/javascript" language="javascript">
function ConfirmDialog() {
if (confirm("You are a new. You wanna sign-in?") == true) {
// call server method
}
}
</script>
...
<asp:Button ID="btnUpload" runat="server" Text="UPLOAD DOC" OnClick="btnUpload_Click" />
UploadDoc.aspx.cs
// ...
private bool btnUpload_Click(List<MyStuff> myList)
{
List<MyStuff> vList = new List<MyStuff>();
bool up = Upload(vList);
// ...
}
private bool Upload(List<MyStuff> myList)
{
bool registered;
// ... other stuffs...
if (registered == true)
{
// do things...
}
else
{
// from here should show the confirm dialog.
System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "ConfirmDialog()", true);
}
}