silverlight 中传递价值

发布于 2024-08-02 17:01:07 字数 703 浏览 2 评论 0原文

如何在 silverlight 中将值从一个页面传递到另一页面。 我有一个 silver light 应用程序,其中包含两个页面、一个 xaml.cs 文件和一个 asmx.cs 文件。我在 xaml 页面中有一个名为 Text1 的文本框。我的要求是在运行时,我可以将文本框值传递给 asmx.cs 文件。它将如何完成? 我在 asmx.cs 文件中的代码是

public string DataInsert(string emp)
    {
        SqlConnection conn = new SqlConnection("Data Source=Nisam\\OFFICESERVERS;Initial Catalog=Employee;Integrated Security=SSPI");
        SqlCommand cmd = new SqlCommand();
        conn.Open();
        cmd.Connection = conn;
        cmd.CommandText = "Insert into  demo Values (@Name)";
        cmd.Parameters.AddWithValue("@Name", xxx);
        cmd.ExecuteNonQuery();
        return "Saved";
    }

代码中的值 xxx 被替换为从 xaml.cs 页面传递的值。请帮助我

How can pass a value from one page to another page in silverlight.
I have one silver light application which contains two pages, one xaml.cs file and one asmx.cs file. I have one text box in xaml page names Text1. My requirement is that at the time of running, i could pass the textbox value to asmx.cs file. How it will be done?
my code in asmx.cs file is

public string DataInsert(string emp)
    {
        SqlConnection conn = new SqlConnection("Data Source=Nisam\\OFFICESERVERS;Initial Catalog=Employee;Integrated Security=SSPI");
        SqlCommand cmd = new SqlCommand();
        conn.Open();
        cmd.Connection = conn;
        cmd.CommandText = "Insert into  demo Values (@Name)";
        cmd.Parameters.AddWithValue("@Name", xxx);
        cmd.ExecuteNonQuery();
        return "Saved";
    }

the value xxx in code is replaced by the passed value from xaml.cs page. pls help me

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

找个人就嫁了吧 2024-08-09 17:01:07

您的 asmx 文件是一个 Web 服务,您必须在 silverlight 应用程序中调用 Web 服务才能与 asmx 进行通信。您将需要创建带有参数的适当的 Web 方法。

Your asmx file is a web service, you will have to invoke web service in your silverlight app to communicate with asmx. And you will need to create appropriate web method with parameters.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文