G
Guest
ok, so I am having problems passing in an ASPX function into the Javascript in the codebehind page. I am simply using a confirm call which when they press "OK" they call this ASPX function, when they press "Cancel" they call another ASPX function.
My code now is:
System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE=""JavaScript"">" & vbCrLf)
System.Web.HttpContext.Current.Response.Write("if (confirm('Are you sure you want to delete the user " & UserID & "')) " & DeleteUser(UserID) & "; else " & list_users(ddSites.SelectedValue) & ";")
System.Web.HttpContext.Current.Response.Write("</SCRIPT>")
which also works as:
Dim strScript As String
strScript = "<script>"
strScript = strScript & "if (confirm('Are you sure you want to delete the user')) " & DeleteUser(UserID) & "; else " & list_users(ddSites.SelectedValue) & ";"
strScript = strScript & "</script>"
RegisterClientScriptBlock("ClientScript", strScript)
It works with one pretty important problem. No matter which order I put the DeleteUser function (on Ok or Cancel button)
it still goes to it and Deletes the user. Obviously, this isn't supposed to happen. If they choose the Cancel button, they should just reload the userlist, without the delete taking place.
If I completely remove the DeleteUser function from the call and make both list_user like this:
strScript = strScript & "if (confirm('Are you sure you want to delete the user')) " & list_users(ddSites.SelectedValue) & "; else " & list_users(ddSites.SelectedValue) & ";"
Then it ignors the Delete function, like it should and just reloads the datagrid. Then of course, the problem is... it never allows you to delete.
By the way... using {} in my Javascript call doesn't seem to matter....
Help?!
My code now is:
System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE=""JavaScript"">" & vbCrLf)
System.Web.HttpContext.Current.Response.Write("if (confirm('Are you sure you want to delete the user " & UserID & "')) " & DeleteUser(UserID) & "; else " & list_users(ddSites.SelectedValue) & ";")
System.Web.HttpContext.Current.Response.Write("</SCRIPT>")
which also works as:
Dim strScript As String
strScript = "<script>"
strScript = strScript & "if (confirm('Are you sure you want to delete the user')) " & DeleteUser(UserID) & "; else " & list_users(ddSites.SelectedValue) & ";"
strScript = strScript & "</script>"
RegisterClientScriptBlock("ClientScript", strScript)
It works with one pretty important problem. No matter which order I put the DeleteUser function (on Ok or Cancel button)
it still goes to it and Deletes the user. Obviously, this isn't supposed to happen. If they choose the Cancel button, they should just reload the userlist, without the delete taking place.
If I completely remove the DeleteUser function from the call and make both list_user like this:
strScript = strScript & "if (confirm('Are you sure you want to delete the user')) " & list_users(ddSites.SelectedValue) & "; else " & list_users(ddSites.SelectedValue) & ";"
Then it ignors the Delete function, like it should and just reloads the datagrid. Then of course, the problem is... it never allows you to delete.
By the way... using {} in my Javascript call doesn't seem to matter....
Help?!