2011-01-07 110 views
-1

我有我的代码有问题,我不能得到它的'测试',以获取值即时尝试分配给它。在运行时设置类属性

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(); 

我试图让这个弹出的对话框中显示,它正在与类似test.account在消息框中显示出越来越不肯定相当的问题是什么。

我的整体问题是我试图在运行时设置类porpert。

任何帮助表示赞赏。

+0

你的代码看起来就好了。你有什么确切的问题?该属性接收空值/空值?您是否尝试过调试以查看变量rec的属性值? – Smur 2011-01-07 16:10:29

+0

不,我得到它的工作感谢您的输入,虽然!仍然试图让它循环结果,然后停在文档的末尾,如果你知道我的意思,就像每个值的单独对话框,你点击确定,然后它提出下一个值,然后当它到达它告诉你的文档的结尾。 – Ebikeneser 2011-01-07 16:41:24

回答

0

是“记录”一个现有的类吗?

这是编译时错误,错误是什么意思?

一个简单的解决方案可能是使用visual studio进行调试,并检查那里的值(如果使用Visual Studio)。


如果您尝试在运行时(而不是开发时间)检查这些值,则可以使用javascript显示消息。

多亏了WebProNew.com文章...
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); 
     } 
    } 
} 

用法......

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"); 
    } 
} 
相关问题