ASP.NET Call Code Behind Function From Javascript -
I have created a webmath that I am trying to call javascript, but this is not flickering. I am holding the index values selected from a list of books within a user control and sending it to my webmooth to remove the chosen user. I have seen countless sites and I have not got the solution. I am not getting any error, everyone else is doing the job. I have called this function behind a public sub-code without any luck. Any suggestions are very appreciated!
& lt;% @ Page language = "VB" AutoEventWireUp = "False" ClientIDMode = "Static" codefile = "Edit.aspx.WB" Inheritance = "_default"% & Gt; & Lt;% @ Register src = "AdminEdit.ascx" tag name = "AdminEdit" tagprefix = "uc1"%> & Lt;% @ TagPrefix = "asp" namespace = "Ajax controlToolkit" assembly = "Ajax controlToolkit"%> & Lt ;! DOCTYPE HTML PUBLIC "- // W3C // DTD XHTML 1.0 Transcription // N" "http: //www.w3 .org / TR / xhtml1 / dTD / xhtml1-transitional.dtd" & gt; & Lt; Html xmlns = "http://www.w3.org/1999/xhtml" & gt; & Lt; Head runat = "server" & gt; & Lt; Title & gt; & Lt; / Title & gt; & Lt; Script type = "text / javascript" & gt; Function YesNo () {var results = confirm ("Are you sure you want to delete?"); If (results == true) {// var strUser = e.options [e.selectedIndex] .value; Var E = document.getElementById ('& lt;% = newLb.clientID% & gt;'); // var e = document.getElementById ("ListBox1"); Var C = E. Selected indices; Var sv = e.value; Document.write ("TRUEEEE"); PageMethods.DeleteUser (sv); } And {document.write ("FALSEEEEEE"); }} & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Form id = "form1" runat = "server" & gt; & Lt; Asp: ScriptManager id = "A1" run = "server" EnablePageMethods = "true" & gt; & Lt; / Asp: ScriptManager & gt; & Lt; Div & gt; & Lt; Asp: Hyperlink ID = "HyperLink 1" Runat = "Server" Navigate = "~ / login.aspx" & gt; Login & lt; / Asp: hyperlink & gt; & Lt; / Div & gt; & Lt; ASP: Hyperlink ID = "HyperLink 2" Runat = "Server" Navigate = "~ / ChangePassword.aspx" & gt; Change Password & lt; / Asp: hyperlink & gt; & Lt; Br / & gt; & Lt; ASP: Hyperlink ID = "HyperLink 3" Runat = "Server" Navigate URL = "~ / CreateUser.aspx" & gt; Create User & lt; / Asp: hyperlink & gt; & Lt; Br / & gt; & Lt; ASP: Hyperlink ID = "Hyperlink 4" Runat = "Server" Navigate URL = "~ / AddRole.aspx" & gt; Add Roles & lt; / Asp: hyperlink & gt; & Lt; Br / & gt; & Lt; Br / & gt; & Lt; Uc1: AdminEdit id = "AdminEdit1" runat = "server" /> & Lt; / Form & gt; & Lt; / Body & gt; & Lt; / Html & gt; Public newLb As New ListBox Protected Sub Page_Load (as the object, such as e EventArgs) Handles Me.Load so Roles.IsUserInRole ( "Administrator") then elseif Roles.IsUserInRole ( "Editor") then newLb = CTYPE (AdminEdit1.FindControl ("ListBloc 1"), Listbox) And End And SubS End Lieutenant; System Web. Services. Webmath () & gt; Public sharing function DeleteUser (ByVal uname As String) As String Dim as newEdit.newLb _newLb.Items.RemoveAt as U MembershipUser dim newEdit New _Default dim _newLb = (0) u = Membership.GetUser (uname ) Membership.DeleteUser (Try U. Username) Pre-Hold as Exception Return "Error:" & amp; Try Ex.message end u.Isprofoved.ToString End Function
I think you should use JSon to call the web method -8 ", url:" yourpage.aspx / yourmethod ", data:" {} ", datatype:" Jason ", success: Function (data) {// write functionality to display data}, error: work (result) {warning ("error");}});
and link Can help you
Comments
Post a Comment