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


 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
LVL 10
GlobaLevelProgrammerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GlobaLevelProgrammerAuthor Commented:
this isnt working;

 HttpContext.Current.Application(do_this(textVal))
0
Pra4444Commented:
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
GlobaLevelProgrammerAuthor Commented:
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
Pra4444Commented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.