Solved

asp.net - call a sub on the server side...even though its shared...

Posted on 2011-02-16
4
333 Views
Last Modified: 2012-05-11

 How can I call a
------

   <WebMethod()> _
    Public Shared Sub SetVariable(ByVal textVal As String,)
        HttpContext.Current.Session("SessionUserFirstName") = textVal
   
        call_this_sub(textVal)

    End Sub
0
Comment
Question by:GlobaLevel
  • 2
  • 2
4 Comments
 
LVL 10

Author Comment

by:GlobaLevel
Comment Utility
this isnt working;

 HttpContext.Current.Application(do_this(textVal))
0
 
LVL 12

Expert Comment

by:Pra4444
Comment Utility
Try creating a new instance of your class that contains the above webmethod and call the sub..

dim myClass as New WebMethodClass
myClass.do_this(textVal)

0
 
LVL 10

Author Comment

by:GlobaLevel
Comment Utility
Pra4444....

thats not working for me...


Imports System.Data.SqlClient

Imports System.IO
Imports System.Data.SqlClient.SqlDataAdapter
Imports System.Data.SqlClient.SqlConnection
Imports System.String
Imports System.StringComparison
Imports System.Text.StringBuilder
Imports System.Web.UI
Imports System.Web.UI.Page
Imports System.Web.UI.WebControls.TextBox
Imports System.Web.UI.WebControls
Imports System.Web.UI.ExtenderControl
Imports System.Random
Imports System.DateTime
Imports System.Data.OleDb
Imports System.Text
Imports System.Data.Odbc
Imports System.Data
Imports System.Text.RegularExpressions
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports System.Web.Services
Imports System.Web.SessionState.HttpSessionState


Partial Class client_online_srvnt
    Inherits System.Web.UI.Page



    <WebMethod()> _
    Public Shared Sub SetVariable(ByVal textVal As String)
        HttpContext.Current.Session("SessionUserFirstName") = textVal
        ' do_this(textval)
        dim myClass as New WebMethodClass
        MyClass.do_this(textVal)


    End Sub

    Public Sub do_this(ByVal textvlas As String)



    End Sub

End Class

Open in new window

0
 
LVL 12

Accepted Solution

by:
Pra4444 earned 500 total points
Comment Utility
Ok...maybe i didnt explain it right....

There are two ways in which you can do it...

one is.... change ur function definition like this..

private shared sub do_this(byval textval as String)

  code for your function...

end sub

call from your webmethod as usual.....



Second way...

Partial Class client_online_srvnt
    Inherits System.Web.UI.Page
   <WebMethod()> _
    Public Shared Sub SetVariable(ByVal textVal As String)
        HttpContext.Current.Session("SessionUserFirstName") = textVal
        ' do_this(textval)
        dim myClass as New HelperClass
        MyClass.do_this(textVal)


    End Sub
'create a new class and write the sub that you need to access....
Public Class HelperClass
    Public sub do_this(byval textval)
                do ur code here...
    End sub
End Class
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now