C# - Object Being Passed Using Webmethod, Loses Some Values But Not All?
Jun 22, 2011
when calling a webmethod
[WebMethod]
public Profile synchronize(string MID, DeviceUploadData data)
The object DeviceUploadData has many properties, and a few of them are array's. My question is about the array specifically. It loses it's value once it's received on the webmethod end.This is the property inside DeviceUploadData
Private data() As DataObject
Public Property Data() As DataObject()
Get
[code]....
So the DataObject is populated with data, then once passed, on the other end, some of the DataObject properties are no longer populated. I haven't included the other properties in this example.
View 1 Replies
ADVERTISEMENT
Nov 12, 2010
I have a class library that contains a number of classes. I would like to dynamically create an instance of one of these classes, set its properties, and call a method.
Example:
Public Interface IExample
Sub DoSomething()
End Interface
Public Class ExampleClass
[Code].....
View 1 Replies
Jun 3, 2009
I'm writing a custom user control for my asp.net site, for storing datetimes. It has two properties:
Private _includeTime As Boolean
Private _value As DateTime = Nothing
Public Property IncludeTime() As Boolean
[code]....
I call my custom control in this way:
<my:DateTimeInput runat="server" includetime="true" ID="txtWhen" />
This sets the includetime property correctly.In my backend code I also do this on page_load:
txtWhen.SelectedDateTime = now
When I step through with the debugger, I see that the property gets set, BUT when the page_load of the control itself loads, the property value is reset to nothing!
The page_load of the control:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
lbltime.Visible = IncludeTime
If SelectedDateTime().CompareTo(Nothing) > 0 Then
[code]....
View 2 Replies
Jun 21, 2012
I have a need for a button to take the user back to their previous page.Because of how this page is accessed, the only way to do this is with javascript using history.back()
This part works perfectly apart from the fact when a user goes to click a button on the page they have gone to back to, I get the error that Request.QueryString is not supported in this context.I'm guessing the Request object is lost when javascript is directing the user to the previous page.I cannot use Request.UrlReffer either because the the nature of the back button. (it causes a loop at times).
View 2 Replies
Jan 18, 2011
I am working on a ASP.NET MVC2 website. For learning. I am working with the Visual Basic language.
In a view I would like to do this:
<%: Html.EditorForEnumeracion(Function(v) v.combustible%>
So, I created an HtmlHelper extension method:
Imports System.Runtime.CompilerServices
Imports System.Linq.Expressions
Imports System.Reflection
[Code]....
View 2 Replies
Mar 11, 2010
I am currently working on a project that requires an update within an Access Database. There are photo folders, and the user defines the path name via a dialog box. That path name is stored to a string value, and through OleDBReader, the actual name of the photo (from another column in the database) is stored to another string value. Anyway, I have tried a number of methods to update, and nothing is working, here is my code from the OleDBReader on, and the procedure designed to do the update. (note that TargetID represents the primary key of the access DB.. this is why I pass that value in because I can use the Rows.Find(PK) method.. When I use a simpler updating method, I get an error saying I do not have a valid update command). OK Here is the code:
Dim photoSQL As String = "SELECT * FROM PotentialTarget"
Dim oleDbCommand As OleDbCommand = New OleDbCommand(photoSQL, tableConn)
Dim oleDbDataReader As OleDbDataReader = oleDbCommand.ExecuteReader()
[Code].....
View 5 Replies
May 19, 2009
I am still developing this function, but here is what I am intending it to do. This function will accept an Object, then try to determine its type. There are a specific set of types I am looking for: Integer, Boolean, Date, String. What I have so far is pretty privative, but it seems to be working so far:
Private Function DataType(ByVal entry As Object) As ValueType
Try
If IsNumeric(entry) Then
[Code].....
View 3 Replies
Nov 12, 2009
I'm not having any errors from these pieces of code, they're just empty everytime. I'm wondering if I perhaps have created them incorrectly.
Dim l As New Log()
l.Log = "Attempted staff login with username [" & txtUsername.Text & "]"
l.LogId = 0
l.StaffId = 4
l.LogDate = Date.Now()
l.Insert()
.Insert() is picked up in my BLL layer by these two functions;
[Code] ......
View 2 Replies
Nov 1, 2009
I'm just learning VB and enjoying it, but I have run into a problem with a recent program. I am working with passing values. There is a button on my form that is pressed each time the user "votes" for an option. The problem is I'm declaring my variables in the button press action, then calling my subs/functions.
This seems to be re-declaring my variables each time the button is pressed causing the total counters to fail to increment. I wrote the code for a very basic example of what I am running into in my more complex program.
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim intGenericValue As Integer
Call GenericSub(intGenericValue)
[code]....
View 3 Replies
Aug 29, 2011
How can I get the name of the object that was passed byref into a method?
Example:
Dim myobject as object
sub mymethod(byref o as object)
debug.print(o.[RealName!!!!])
end sub
[code]....
I'm using this for logging. I use one method multiple times and it would be nice to log the name of the variable that I passed to it. Since I'm passing it byref, I should be able to get this name, right?This would give you the parameter name in the method and it's type, but not the name of the variable that was passed byref.
using system.reflection
Dim mb As MethodBase = MethodInfo.GetCurrentMethod()
For Each pi As ParameterInfo In mb.GetParameters()
[code]....
If you put that in "mymethod" above you'd get "o" and "Object".
View 3 Replies
Dec 1, 2011
I'm having trouble creating a sub that can create objects of a variable type on the fly. Here's an example of what I'm trying to achieve:
[Code]...
I can't get it to work. I've done a fair bit of research, and looked at generic types, reflection, and other tools, but I'm having trouble determining how best to tackle this problem.
View 3 Replies
Jun 10, 2008
Once again I have hit a brick wall here. I have a combobox in which the user types the server name and then clicks on button 'CONNECT' to populate the next combobox which contains all the databases in that
server. Then after the user selects a database, I have another button that he/she click and I want to retrieve file groups from a specific table. At this point when he/she clicks on that button I get an error: "An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)"
[Code]...
View 1 Replies
Sep 25, 2010
I have a situation that has puzzled me for weeks. I am running logic that does a bit of back and forth to and from the database for each time it is executed (about 20 times). The problem is that the same code works about half of the time. What could possibly be the reason for the difference in execution performance and how can I better shore that this problem is checked?
View 1 Replies
Apr 18, 2011
I've mainly been recording keystrok macros... I created visual basic code that allows the user of a template to hide table gridlines - which works fine. The code to show gridlines does not work if the table has only one row. Here is the code - it is getting "stuck" on the
.LineWidth = wd
LineWidth050pt for a horizontal border, as there isn't one. I don't know how to change the code to not execute the command if a horizontal border line does not exist.
With Selection.tables(1)
With .Borders(wdBorderLeft)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = 5592405
[Code] .....
View 2 Replies
Mar 23, 2012
I want to pass a List of T where T is an object I've created that has about ten properties (strings, dates and integers).The lst passes to the function successfully. I am also passing an New T of the Object (itm as T).I can see all the values (see image below), but because it's generic I cannot seem to retrieve the property values and I cannot figure out how to iterate through the properties of each itm as they are retrieved in the For Each.[code]
View 10 Replies
Aug 18, 2009
I have some classes, BsfciFile and StudyFlashCard. Bsfci is the extension to which I save my set of flashcards in an INI format. I am currently working to transform my code from using Windows API calls to access the INI to using a IniFile class that I found on the internet. I would like the BsfciFile to have a Array of StudyFlashCard objects, but I would like the StudyFlashCard class to use the IniFile class object contained in the BsfciFile class. I can pass the IniFile from the BsfciFile class to the constructor for the StudyFlashCard class, but I want it to modify the same IniFile as the BsfciFile class has later on.
[Code]...
View 1 Replies
Feb 18, 2010
Hi
I've got a pretty general question about the best practice in passing an object reference to a Form in VB.NET. My form is a dialog and I've created an overload ShowDialog method, where I pass an Object into it ByRef.
The trouble is, I want to be able to refer to that Object throughout my dialog Class and not just in the ShowDialog method. For instance, some of my Events for controls on the form, need to reference that object.
I know I could create a local Private variable in the Class and assign it to the passed value, and then use that value. However I'm thinking this isn't very efficient because it would (I believe) create a new copy of the Object (which is a complex, large class in itself).
View 8 Replies
Apr 26, 2010
I'm having a problem with passing on values from my data grid view to a textbox located in another form.[code]
View 2 Replies
Aug 13, 2011
I'm trying to code a class of RandomNumber. One of the class methods needs to populate a "List (Of RandomNumber)" ... which was passed as a parameter to the method ... with 10 random numbers between 1 and 50. DEAD SIMPLE :)
View 6 Replies
Jan 12, 2012
I did the web method below using C#. I'm tryin to convert this into VB.NET, but I'm missing something. I'm using it with an ajax calling, from a paginator/sorter table plugin.
[WebMethod( EnableSession = true )]
public static object listaPessoas(int jtStartIndex = 0,
int jtPageSize = 0, [code].....
Second, I don't know how to return the message "OK" and the list of people.
View 1 Replies
Jan 21, 2011
I have an ASP.NET C# project consuming webservices and WebMethods are wrote in VB.NET with source code on a local IIS server. The WebMethod returns null, and I want to debug it to know why I get this.
View 2 Replies
May 25, 2012
my code calls a WebMethod. Within that WebMethod I have the need to create a new control collection. In VB I would normally write:
Dim cc As System.Web.UI.ControlCollection = CreateControlCollection()
But because I'm inside a WebMethod, I get the error :
Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class.
View 1 Replies
May 31, 2011
I'm trying to eliminate a VB.NET button on my aspx page. Trying to use javascript and ajax to execute the same code my vb had.I put in a script manager, set EnablePageMethods to true, added a static subroutine, and referred to it in my javascript function (BTW -- this seems a lot of work just to execute an existing subroutine). The javascript calls my code-behind and it almost works.Problem is, now I'm getting a NullReferenceException when SimulatePrintBatchClick tries to do anything with the controls.
Error is 'Object reference not set to an instance of an object', line is 'pnlVars.Controls.Clear'
Here's the code from UW.aspx:
<WebMethod()> _
Public Shared Sub PrintBatchFromJSWM()
Dim UWI As New UW
[code]....
when I run the above code in PrintBatch_Click it all executes just fine. I really don't understand why it bombs out as a subroutine.
Perhaps this is not the way to do this, but I'm at a loss for finding a different way. Originally this code was handled by an ASP/VB button, but the specs have called for it to be deleted.
View 1 Replies
Jul 30, 2011
I am using an ajax PageMethod to call an asp.net webmethod. From there I'm trying to pass a lot of XML back to a callback javascript function.
Currently I just convert the XML into a string and pass it in that format. But it seems that if the string is too long it causes an error.
[Code]...
So my question is: Is there a better way to pass the XML from VB to javascript, or a way to allow large strings to be passed without error?
View 1 Replies
May 12, 2011
In a page to create new user accounts, we have a database with a little of allowable users. To streamline getting the Email address of the new user correct, we want to use an AutoComplete extended textbox.Now I know that WebMethods are working because I have a cascading-drop-down tied to web methods in another page.As I'm just starting on this page, the code is simple.The page itself:
<cc1:ToolkitScriptManager ID="ScriptManager2" runat="server"/>
<p></p> Please enter new user's Email:
<asp:TextBox ID="txtUser" runat="server" />
<cc1:AutoCompleteExtender runat="server" ID="autUser" TargetControlID="txtUser"
[code]....
I'm not even getting to the LogDebug statement. I've used all the same boilerplate code (Inherits, the 'WebService' tags, etc) that worked in the other WebMethod with the appropriate changes to the Class name but this really has me stumped.
View 1 Replies
Jul 12, 2011
I have a VB.NET function which looks like this:
<WebMethod()> _
Public Shared Function AuthenticateUser(ByVal UserInfo As String, ByVal Password As String) As Boolean
Dim UserName As String
[code]....
It calls the function, but won't return a value. When walking through the code, my VB function does fire (it will return true so long as the correct password is typed in), but the javascript 'authenticated' value remains 'undefined'. It's like you can't return values from VB functions to javascript.
I also tried
if PageMethods.AuthenticateUser("UserName", "Password")
{
//Stuff
}
But still no luck.
View 1 Replies
May 10, 2011
I'm developing a website with ASP and VB.NET 4. I'm also using the FullCalendar jQuery plugin, but I have a trouble: catching a parameter from querystring to the webmethod in the .asmx. I've tried to refer the querystring property with the Request.QueryString() and it doesn't work.
Here's the webmethod:
<%@ WebService Language="VB" Class="wbsCalendario" %>
Imports System.Web
Imports System.Data
[Code].....
View 1 Replies
Jun 18, 2012
here my function
<WebMethod()>
Public Shared Function person() As List(Of Class1)
Dim initialState = {New Class1 With {.id = 1,
[Code]....
how to pass initialstate values to knockout?
View 2 Replies
Mar 23, 2012
I'm trying to use an auto-complete, and it works fine if I call a function without a parameter in the web service:
<WebMethod()> _
<Script.Services.ScriptMethod()> _
Public Function GetCompanyNames2() As String()
[code].....
View 1 Replies
Aug 18, 2009
I have a Web Service with one WebMethod for which return value is boolean.It accepts XML file as string and process data. How can I first return status as true and then call the ProcessData method.
As the processing data takes time I need to return true first and then process the data.
[webmethod]
Public function receiveData(ByVal xmlstr as string) as boolean
dim status as boolean=false
try
[Code]...
View 2 Replies