-1

I have a problem with my code, I cannot get it the 'test' to get the values im trying to assign to it.

rec = new Record(perosn, actually, com, Centre, CCentre);
webservicename.singleSummary test = new webservicename.singleSummary();

test.person = rec.person;
test.actually = recc.Actually;
test.com = rec.Com;
test.Centre = rec.Centre;
test.CCentre = rec.CCentre;

webservicename.Feed CallWebService = new webservicename.Feed();

I am trying to get this to pop up in a dialog box to show that it is working, with something like test.account getting showed in the message box, not sure quite what the problem is.

My overall problem is I am trying to set the class porpert at runtime.

Any help is appreciated.

Ebikeneser
  • 2,582
  • 13
  • 57
  • 111
  • Your code looks just fine. What exact problem are you getting? The properties are receiving null / empty values? Have you tried debugging to see the variable rec's properties' values? – Smur Jan 07 '11 at 16:10
  • no i have got it working thanks for your imput though! Still trying to get it to loop the results and then stop at the end of the document if you know what I mean, like a seperate dialog box for each value, you click ok then it brings up the next value, then when it gets to the end of the document it tells you. – Ebikeneser Jan 07 '11 at 16:41
  • your question doesn't contain anything from your last comment. You need to clarify your question with more information if you want meaningful answers. –  Jan 07 '11 at 18:45

1 Answers1

0

Is "Record" an existing class?

Is this a compile time error and what does the error say?

One simple solution might be to debug into this using visual studio and check the values there, (if your using Visual Studio).


If you're trying check these values at run time (not development time) then you could use javascript to display a message.

Thanks to a WebProNew.com article...
http://www.webpronews.com/expertarticles/2006/11/29/javascript-alertshowmessage-from-aspnet-codebehind

using System.Web;
using System.Text;
using System.Web.UI;

/// 
/// A JavaScript alert
/// 
public static class Alert
{
    /// 
    /// Shows a client-side JavaScript alert in the browser.
    /// 
    /// The message to appear in the alert.
    public static void Show(string message)
    {
       // Cleans the message to allow single quotation marks
       string cleanMessage = message.Replace("'", "\\'");
       string script = "alert('" + cleanMessage + "');";

       // Gets the executing web page
       Page page = HttpContext.Current.CurrentHandler as Page;

       // Checks if the handler is a Page and that the script isn't allready on the Page
       if (page != null && !page.ClientScript.IsClientScriptBlockRegistered("alert"))
       {
         page.ClientScript.RegisterClientScriptBlock(typeof(Alert), "alert", script);
       }
    }
}

Usage...

void btnSave_Click(object sender, EventArgs e)
{
   try
   {
     SaveSomething();
     Alert.Show("You document has been saved");
   }
   catch (ReadOnlyException)
   {
     Alert.Show("You do not have write permission to this file");
   }
}
Martin Buberl
  • 45,844
  • 25
  • 100
  • 144
John K.
  • 5,426
  • 1
  • 21
  • 20