473,414 Members | 1,775 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

CLASS PROBLEM

<%@ WebService Language="C#" Class="Tecrube" %>
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
[WebService(Namespace = "http://www.aaaa.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

public class Tecrube : System.Web.Services.WebService {
public DateTime Tarih;
public Tecrube()
{
Tarih = DateTime.Now;
}

[WebMethod]
public string MerhabaDunya()
{
return Tarih.ToString();
}

}

Using System;
using System.Windows.Forms;

namespace WS_Tecrube_01
{
public partial class Form2 : Form
{
private WebSeTcrb.Tecrube S;
public Form2()
{
InitializeComponent();
S = new WebSeTcrb.Tecrube();
}

private void button1_Click(object sender, EventArgs e)
{
textBox1.Text = S.MerhabaDunya();
}
}
}

When i click the Button1 it returns the time when i clicked the button. I
suppose to see the time when the form initiliaze.
What can be the problem ?
Sep 5 '06 #1
2 1402
When you click the button, clientside javascript (inserted by ASP.NET)
resubmits the page, and the form data detects that we clicked this button
and invokes the button1_Click() handler. You are seeing the "S" from the
second drawing of the page. Incidentally, this usage will not use the
[WebMethod] - so this may not be requireed. If you need to persist the "S"
between calls, you will need to use state (either view-state or
session-state), as ASP.NET is generally stateless.

Marc
Sep 5 '06 #2
Hi,

You can call & store the value in Form2's constructor:

public partial class Form2 : Form
{
private WebSeTcrb.Tecrube S;
string s;
public Form2()
{
InitializeComponent();
S = new WebSeTcrb.Tecrube();
s = S.MerhabaDunya();
}

private void button1_Click(object sender, EventArgs e)
{
textBox1.Text = s; }

--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Savas Ates" <in da clubwrote in message
news:e2**************@TK2MSFTNGP06.phx.gbl...
<%@ WebService Language="C#" Class="Tecrube" %>
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
[WebService(Namespace = "http://www.aaaa.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

public class Tecrube : System.Web.Services.WebService {
public DateTime Tarih;
public Tecrube()
{
Tarih = DateTime.Now;
}

[WebMethod]
public string MerhabaDunya()
{
return Tarih.ToString();
}

}

Using System;
using System.Windows.Forms;

namespace WS_Tecrube_01
{
public partial class Form2 : Form
{
private WebSeTcrb.Tecrube S;
public Form2()
{
InitializeComponent();
S = new WebSeTcrb.Tecrube();
}

private void button1_Click(object sender, EventArgs e)
{
textBox1.Text = S.MerhabaDunya();
}
}
}

When i click the Button1 it returns the time when i clicked the button. I
suppose to see the time when the form initiliaze.
What can be the problem ?


Sep 5 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Steve | last post by:
Hello, I'm encountering an unexpected behavior when using the "new" modifier in a derived class to hide an inherited base class property. I use "new" intentionally so I can change the Type of...
9
by: Banaticus Bart | last post by:
I wrote an abstract base class from which I've derived a few other classes. I'd like to create a base class array where each element is an instance of a derived object. I can create a base class...
21
by: Jon Slaughter | last post by:
I have a class that is basicaly duplicated throughout several files with only members names changing according to the class name yet with virtually the exact same coding going on. e.g. class...
21
by: Mark Broadbent | last post by:
Consider the following statements //------- Item i = Basket.Items; //indexer is used to return instance of class Item Basket.Items.Remove(); //method on class item is fired item i = new...
5
by: Nick Flandry | last post by:
I'm running into an Invalid Cast Exception on an ASP.NET application that runs fine in my development environment (Win2K server running IIS 5) and a test environment (also Win2K server running IIS...
8
by: tshad | last post by:
I cannot seem to get the asp:textbox to use classes. Style works fine. I am trying to set the textbox to act like a label in some instance so it doesn't have a border, readonly and the background...
4
by: Tony Johansson | last post by:
Hello! I have one solution file that consist of three project. One project that build the exe file called A One project that build a user control dll. Here we have a class called B One project...
5
by: tony | last post by:
Hello! This is a rather long mail but it's a very interesting one. I hope you read it. I have tried several times to get an answer to this mail but I have not get any answer saying something...
3
by: Hamilton Woods | last post by:
Diehards, I developed a template matrix class back around 1992 using Borland C++ 4.5 (ancestor of C++ Builder) and haven't touched it until a few days ago. I pulled it from the freezer and...
3
by: TamusJRoyce | last post by:
Hello. This is my first thread here. My problem has probably been came across by a lot of people, but tutorials and things I've seen don't address it (usually too basic). My problem is that I...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.