powered by simpleCommunicator - 2.0.59     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / ASP.NET [игнор отключен] [закрыт для гостей] / Context.Handler
4 сообщений из 4, страница 1 из 1
Context.Handler
    #39223147
jango77
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Здравствуйте
По задаче нужно передать логин при авторизации с первой страницы на вторую в тейбл
Руководствовался этим ресурсом
Первая форма:

Код: c#
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
protected void Page_Load(object sender, EventArgs e)
        {
           
        }

        protected void authorization()
        {
            int res = confirmation(Txtbx_Login.Text, Txtbx_Password.Text);
            if (res == 1)
            {
                Response.Redirect("/AddingInfo.aspx");
            }
            else
            {
                Txtbx_Login.Text = null;
                Txtbx_Password.Text = null;
            }
        }

        public string Login
        {
            get
            {
                return Txtbx_Login.Text;
            }
        }



        protected int confirmation(string Userlogin, string UserPassword)
        {
            Int32 authstatus = 0;
            using (SqlConnection conn = new SqlConnection(@"Data Source="))
            using (SqlCommand cmd = new SqlCommand("p_authorization_confirmation", conn))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@login", SqlDbType.Text).Value = Userlogin;
                cmd.Parameters.Add("@password", SqlDbType.Text).Value = UserPassword;

                var returnParameter = cmd.Parameters.Add("@ReturnVal", SqlDbType.Int);
                returnParameter.Direction = ParameterDirection.ReturnValue;

                try
                {
                    conn.Open();
                    cmd.ExecuteNonQuery();
                    authstatus = (Int32)cmd.ExecuteScalar();
                    conn.Close();
                }
                catch (Exception ex) { }
            }

            return (int)authstatus;
        }

        protected void ImageButtonAuth_Click(object sender, ImageClickEventArgs e)
        {
            authorization();
            Server.Transfer("AddingInfo.aspx");
        }



Вторая форма:

Код: c#
1.
2.
3.
4.
5.
6.
protected void Page_Load(object sender, EventArgs e)
        {
            Default wf1;
            wf1 = (Default)Context.Handler;
            Label1.Text = wf1.Login;
        }



Сделал вроде так же как и в примере
И типы объектов такие же, но появляется ошибка http://prntscr.com/avvcyt

Вроде везде string.. Наведите на мысль, что не так
...
Рейтинг: 0 / 0
Context.Handler
    #39223466
jango77
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Здесь пишут что возможно нужно переводить IIS в стандартный режим.
Microsoft рекомендуют использовать интеграцийный
Посоветуйте, может есть другой способ передать логин с дропдаунлиста первой страницы на вторую?
Не через URL и кукисы не хочется использовать
...
Рейтинг: 0 / 0
Context.Handler
    #39223481
jango77
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Нашел статью

Вторая форма
Код: c#
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
public partial class AddingInfo : System.Web.UI.Page
    {
        string userid = null;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.PreviousPage != null)
            {
                DropDownList SourceDropDownListUser = (DropDownList)Page.PreviousPage.FindControl("DropDownListUser");
                if (SourceDropDownListUser != null)
                {
                    userid = SourceDropDownListUser.SelectedValue;
                }
            }

        }



Первая форма
Код: c#
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
 public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
           
        }

        protected void authorization()
        {
            int res = confirmation(DropDownListUser.SelectedValue, Txtbx_Password.Text);  // Значение DropDownListUser.SelectedValue нужно передать на вторую форму
            if (res == 1)
            {
                Response.Redirect("/AddingInfo.aspx");
            }
            else
            {
                Txtbx_Password.Text = null;
            }
        }

 protected void ImageButtonAuth_Click(object sender, ImageClickEventArgs e)
        {
            authorization();
        }
    }



Код первой страницы
Код: xml
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ControlersPortal.Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <style type="text/css">
        .auto-style1 {
            width: 25%;
            background-image: url('fon_bl.jpg');
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Panel ID="Panel1" runat="server" Height="300px"></asp:Panel>
        <asp:Panel ID="Panel2" runat="server">
            <table align="center" class="auto-style1">
                <tr>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>
                        <asp:Label ID="Lbl_Login" runat="server" Font-Bold="True" ForeColor="White" Text="Логин"></asp:Label>
                    </td>
                    <td>&nbsp;</td>
                    <td>
                        <asp:DropDownList ID="DropDownListUser" runat="server" DataSourceID="LinqDataSource1" DataTextField="UserName" DataValueField="UserID">
                        </asp:DropDownList>
                    </td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>
                        <asp:LinqDataSource ID="LinqDataSource1" runat="server" ContextTypeName="ControlersPortal.LinqSQLDataContext" TableName="v_Users">
                        </asp:LinqDataSource>
                    </td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>
                        <asp:Label ID="Lbl_Password" runat="server" Font-Bold="True" ForeColor="White" Text="Пароль"></asp:Label>
                    </td>
                    <td>&nbsp;</td>
                    <td>
                        <asp:TextBox ID="Txtbx_Password" runat="server" TextMode="Password"></asp:TextBox>
                    </td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>
                        <asp:ImageButton ID="ImageButtonAuth" runat="server" Height="20px" ImageUrl="~/Btn_bl.jpg" Width="68px" OnClick="ImageButtonAuth_Click" />
                    </td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                </tr>
            </table>
        </asp:Panel>
        <asp:Panel ID="Panel3" runat="server"></asp:Panel>
    </div>
    </form>
</body>
</html>



Помогите пожалуйста
...
Рейтинг: 0 / 0
Context.Handler
    #39223727
jango77
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Реализовал так
...
Рейтинг: 0 / 0
4 сообщений из 4, страница 1 из 1
Форумы / ASP.NET [игнор отключен] [закрыт для гостей] / Context.Handler
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]