PC Review


Reply
Thread Tools Rate Thread

CLASS PROBLEM

 
 
Savas Ates
Guest
Posts: n/a
 
      5th Sep 2006
<%@ 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 ?


 
Reply With Quote
 
 
 
 
Marc Gravell
Guest
Posts: n/a
 
      5th Sep 2006
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


 
Reply With Quote
 
Ignacio Machin \( .NET/ C# MVP \)
Guest
Posts: n/a
 
      5th Sep 2006
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 club> wrote in message
news:(E-Mail Removed)...
> <%@ 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 ?
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
XMLSerializer problem, class inside class Kristopher Wragg Microsoft C# .NET 0 5th Mar 2007 03:00 PM
problem with accessrights when having a class in another class tony Microsoft C# .NET 1 31st Aug 2006 09:40 AM
Problem accessing Properties of class, not sure if class =?Utf-8?B?TWljcm9Nb3Ro?= Microsoft C# .NET 3 27th Jul 2006 02:23 PM
Having problem with class decaration when Building a class libraray tony Microsoft C# .NET 2 21st Mar 2006 09:33 AM
Problem in deriving class from XmlNode BCL class Mahesh Devjibhai Dhola Microsoft C# .NET 5 15th Oct 2004 01:46 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:20 AM.