本文介绍了如何从非窗体CS文件调用窗体控件。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在ascx文件后面定义了一个cs文件,该文件在aspx页面中调用。我想显示一个弹出输入消息框,从用户那里获取用户名和密码输入,验证它,然后在我的ascx.cs文件中执行一些操作。我没有在谷歌获得一个这个
的例子。它写的如何从另一个表单对象调用一个窗体。

I have a cs file defined behind a ascx file which in tern called in an aspx page. I wanted to show a popup input message box to take user name and password inputs from the user , verify it and then do some actions in my ascx.cs file. I didn't get a single example of this in google. everywhere its written how to call a windows form from another form object.

我的ascx.cs文件代码是

my ascx.cs file code is

protected void btnSubmit_Click(object sender, EventArgs e)

        {

            if(!Page.IsValid)

               返回;

            var contact = new ContactEntity();

            contact.LastName = txtLastName.Text;

            contact.FirstName = txtFirstName.Text;

            contact.Role = ddlRole.SelectedValue;

            contact.EmailAddress = txtEmail.Text;

             _contactUiProvider.CreatePrimaryWebUser(ContactUIProvider.CurrentContact.AccountSelected.AccountId,

                            contact.EmailAddress)

protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (!Page.IsValid)
                return;
           var contact = new ContactEntity();
            contact.LastName = txtLastName.Text;
            contact.FirstName = txtFirstName.Text;
            contact.Role = ddlRole.SelectedValue;
            contact.EmailAddress = txtEmail.Text;
            _contactUiProvider.CreatePrimaryWebUser(ContactUIProvider.CurrentContact.AccountSelected.AccountId,
                                                    contact.EmailAddress)

}

我的表单cs文件代码是 

and my form cs file code is 

推荐答案


Hi Sahenaz,

如果你想从另一个项目调用Winform,你需要 添加winform项目作为参考 ,然后将其用作类:

If you want to call a Winform from another project, you need to add the winform project as a reference, then use it as a class:

    VerifyPassword vp = new VerifyPassword();
    string userName = vp.UserName;

注意:我认为你的问题与从ASP.NET应用程序调用项目更相关,它会更多适合以
提问。

Note: I think your problem is more related to call a project from ASP.NET application, it will be more appropriate to ask your question atASP.NET Forums.

感谢您的理解。

问候,

Stanly


这篇关于如何从非窗体CS文件调用窗体控件。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 02:50