Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2011-02-16
4
Medium Priority
?
350 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 10

Author Comment

by:GlobaLevel
ID: 34911573
this isnt working;

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

Expert Comment

by:Pra4444
ID: 34911745
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
ID: 34917790
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 2000 total points
ID: 34918009
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
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…
Suggested Courses

609 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