- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试运行 项目.aspx . Admin.apsx,当单击“查看配置文件”按钮时,应该创建一个 session “project_id”,因此两个 SQLDataSources 从 Session(“project_id”) 中获取 project_id 值。
我收到此错误:
项目.aspx
<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Project.aspx.vb" Inherits="Project" %>
<%@ Register assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" namespace="System.Web.UI.DataVisualization.Charting" tagprefix="asp" %>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div id="project-image"><asp:Image ID="Image1" runat="server" Height="124px" Width="93px" />
<asp:FormView ID="frmViewProject" runat="server" DataKeyNames="project_id" DataSourceID="SqlDataSource1" HorizontalAlign="Justify">
<EditItemTemplate>
project_id:
<asp:Label ID="project_idLabel1" runat="server" Text='<%# Eval("project_id") %>' />
<br />
project_type:
<asp:TextBox ID="project_typeTextBox" runat="server" Text='<%# Bind("project_type") %>' />
<br />
project_start:
<asp:TextBox ID="project_startTextBox" runat="server" Text='<%# Bind("project_start") %>' />
<br />
project_finish:
<asp:TextBox ID="project_finishTextBox" runat="server" Text='<%# Bind("project_finish") %>' />
<br />
project_duration:
<asp:TextBox ID="project_durationTextBox" runat="server" Text='<%# Bind("project_duration") %>' />
<br />
project_budget:
<asp:TextBox ID="project_budgetTextBox" runat="server" Text='<%# Bind("project_budget") %>' />
<br />
project_cost:
<asp:TextBox ID="project_costTextBox" runat="server" Text='<%# Bind("project_cost") %>' />
<br />
project_name:
<asp:TextBox ID="project_nameTextBox" runat="server" Text='<%# Bind("project_name") %>' />
<br />
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update" Text="Update" />
<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</EditItemTemplate>
<EditRowStyle BorderStyle="Solid" Font-Bold="False" Font-Names="Verdana" Font-Overline="False" Font-Size="Small" HorizontalAlign="Right" VerticalAlign="Middle" />
<InsertItemTemplate>
project_type:
<asp:TextBox ID="project_typeTextBox" runat="server" Text='<%# Bind("project_type") %>' />
<br />
project_start:
<asp:TextBox ID="project_startTextBox" runat="server" Text='<%# Bind("project_start") %>' />
<br />
project_finish:
<asp:TextBox ID="project_finishTextBox" runat="server" Text='<%# Bind("project_finish") %>' />
<br />
project_duration:
<asp:TextBox ID="project_durationTextBox" runat="server" Text='<%# Bind("project_duration") %>' />
<br />
project_budget:
<asp:TextBox ID="project_budgetTextBox" runat="server" Text='<%# Bind("project_budget") %>' />
<br />
project_cost:
<asp:TextBox ID="project_costTextBox" runat="server" Text='<%# Bind("project_cost") %>' />
<br />
project_name:
<asp:TextBox ID="project_nameTextBox" runat="server" Text='<%# Bind("project_name") %>' />
<br />
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert" Text="Insert" />
<asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</InsertItemTemplate>
<InsertRowStyle HorizontalAlign="Center" VerticalAlign="Middle" />
<ItemTemplate>
project_id:
<asp:Label ID="project_idLabel" runat="server" Text='<%# Eval("project_id") %>' />
<br />
project_type:
<asp:Label ID="project_typeLabel" runat="server" Text='<%# Bind("project_type") %>' />
<br />
project_start:
<asp:Label ID="project_startLabel" runat="server" Text='<%# Bind("project_start") %>' />
<br />
project_finish:
<asp:Label ID="project_finishLabel" runat="server" Text='<%# Bind("project_finish") %>' />
<br />
project_duration:
<asp:Label ID="project_durationLabel" runat="server" Text='<%# Bind("project_duration") %>' />
<br />
project_budget:
<asp:Label ID="project_budgetLabel" runat="server" Text='<%# Bind("project_budget") %>' />
<br />
project_cost:
<asp:Label ID="project_costLabel" runat="server" Text='<%# Bind("project_cost") %>' />
<br />
project_name:
<asp:Label ID="project_nameLabel" runat="server" Text='<%# Bind("project_name") %>' />
<br />
</ItemTemplate>
<RowStyle BorderStyle="None" HorizontalAlign="Left" VerticalAlign="Middle" />
</asp:FormView>
<asp:Chart ID="chrtComplete" runat="server" DataMember="DefaultView" DataSourceID="SqlDataSource2" EnableViewState="True">
<series>
<asp:Series ChartType="Pie" Legend="Completed" Name="Series1" XValueMember="project_start" YValueMembers="project_finish">
</asp:Series>
</series>
<chartareas>
<asp:ChartArea Name="ChartArea1">
</asp:ChartArea>
</chartareas>
<Legends>
<asp:Legend LegendStyle="Row" Name="Completed">
</asp:Legend>
</Legends>
<Titles>
<asp:Title Name="Project Completion">
</asp:Title>
</Titles>
</asp:Chart>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ConnStringDb1 %>" SelectCommand="SELECT [project_start], [project_finish] FROM [projects] WHERE ([project_id] = @project_id)">
<SelectParameters>
<asp:SessionParameter Name="project_id" SessionField="project_id" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</div>
<div id="project-info">
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnStringDb1 %>" SelectCommand="SELECT [project_id], [project_type], [project_start], [project_finish], [project_duration], [project_budget], [project_cost], [project_name] FROM [projects] WHERE ([project_id] = @project_id)">
<SelectParameters>
<asp:SessionParameter Name="project_id" SessionField="project_id" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</div>
<br />
</asp:Content>
Imports System.Data.SqlClient
Partial Class Admin
Inherits System.Web.UI.Page
Protected Sub btnSearchUser_Click(sender As Object, e As EventArgs) Handles btnSearchUser.Click
Dim conn As New SqlConnection("Data Source=BRIAN-PC\SQLEXPRESS;Initial Catalog=master_db;Integrated Security=True")
Dim searchComm As String = "SELECT username FROM users WHERE CONTAINS (username, @username)"
Dim searchSQL As New SqlCommand
conn.Open()
searchSQL = New SqlCommand(searchComm, conn)
searchSQL.Parameters.AddWithValue("@username", txtUserSearch.Text)
Dim datareader As SqlDataReader = searchSQL.ExecuteReader()
While datareader.Read
lstUsers.Items.Add(datareader.Item("username"))
End While
datareader.Close()
conn.Close()
End Sub
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
End Sub
Protected Sub DropDownList1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles drpProjects.SelectedIndexChanged
Dim conn As New SqlConnection("Data Source=BRIAN-PC\SQLEXPRESS;Initial Catalog=master_db;Integrated Security=True")
Dim sqlComm As String = "SELECT project_name FROM projects WHERE project_name=@projectname"
Dim sqlProjname As New SqlCommand
conn.Open()
sqlProjname = New SqlCommand(sqlComm, conn)
sqlProjname.Parameters.AddWithValue("@projectname", drpProjects.SelectedItem.Text)
Dim datareader As SqlDataReader = sqlProjname.ExecuteReader()
datareader.Read()
If datareader.HasRows Then
lblProjName.Text = datareader("project_name").ToString()
End If
datareader.Close()
conn.Close()
lblProjName.Visible = True
grdProjDetails.Visible = True
End Sub
Protected Sub btnManageProj_Click(sender As Object, e As EventArgs) Handles btnManageProj.Click
MultiView1.SetActiveView(View2)
End Sub
Protected Sub btnProjSettings_Click(sender As Object, e As EventArgs) Handles btnProjSettings.Click
Dim conn2 As New SqlConnection("Data Source=BRIAN-PC\SQLEXPRESS;Initial Catalog=master_db;Integrated Security=True")
Dim sqlComm2 As String = "SELECT project_id FROM projects WHERE project_name=@projectname"
Dim sqlProjID As New SqlCommand
conn2.Open()
sqlProjID = New SqlCommand(sqlComm2, conn2)
sqlProjID.Parameters.AddWithValue("@projectname", drpProjects.SelectedItem.Text)
Dim datareader As SqlDataReader = sqlProjID.ExecuteReader()
datareader.Read()
If datareader.HasRows Then
Dim UserID As String
UserID = datareader("project_id").ToString
Session("project_id") = UserID
Server.Transfer("Project.aspx", True)
End If
datareader.Close()
conn2.Close()
End Sub
End Class
<%@ Master Language="VB" CodeFile="MasterPage.master.vb" Inherits="MasterPage" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<script runat="server">
Protected Sub Page_Load(sender As Object, e As EventArgs)
If Session("userid") = Nothing Then
txtLoginUser.Visible = True
txtLoginPass.Visible = True
Else
Dim conn As New SqlConnection("Data Source=BRIAN-PC\SQLEXPRESS;Initial Catalog=master_db;Integrated Security=True")
Dim useridComm As String = "SELECT name, surname FROM users WHERE user_id=@userid"
Dim sqlUserID As New SqlCommand
conn.Open()
Dim userid As String = Session("userid")
sqlUserID = New SqlCommand(useridComm, conn)
sqlUserID.Parameters.AddWithValue("@userid", userid)
Dim datareader As SqlDataReader = sqlUserID.ExecuteReader()
If datareader.HasRows Then
FormsAuthentication.RedirectFromLoginPage(datareader("user_id"), True)
lblLoggedIn.Text = datareader("name").ToString() & " " & datareader("surname").ToString()
End If
datareader.Close()
conn.Close()
End If
End Sub
Protected Sub Button1_Click(sender As Object, e As EventArgs)
Dim loginSQL As New SqlCommand
Dim loginComm As String
Dim CommonFunctions As New CommonFunctions()
Dim dec_pass As String = CommonFunctions.EncryptPassword(txtLoginPass.Text.Trim)
Dim conn As New SqlConnection("Data Source=BRIAN-PC\SQLEXPRESS;Initial Catalog=master_db;Integrated Security=True")
loginComm = "SELECT user_id FROM users WHERE username=@username and password=@password"
conn.Open()
loginSQL = New SqlCommand(loginComm, conn)
loginSQL.Parameters.AddWithValue("@username", txtLoginUser.Text.ToString)
loginSQL.Parameters.AddWithValue("@password", dec_pass)
Dim dr As SqlDataReader = loginSQL.ExecuteReader()
dr.Read()
If dr.HasRows Then
Session("userid") = dr("user_id")
ElseIf dr.HasRows = False Then
lblRegister.ForeColor = Drawing.Color.Red
lblRegister.Text = "Incorrect Username/Password."
End If
dr.Close()
conn.Close()
End Sub
</script>
<head>
<meta charset="utf-8" />
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<title></title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link rel="stylesheet" href="style.css" type="text/css" media="screen, projection" />
</head>
<body>
<form id="form1" runat="server">
<div id="wrapper">
<header id="header">
<strong>Header:</strong> Mobile CMS
</header>
<section id="login">
<div id="login-form">
<p>
<asp:Label ID="lblUsername" runat="server" Font-Bold="True" Text="U:"></asp:Label>
<asp:TextBox ID="txtLoginUser" runat="server" BorderStyle="None" BorderWidth="0px" Wrap="False"></asp:TextBox>
<asp:Label ID="lblUsername0" runat="server" Font-Bold="True" Text="P:"></asp:Label>
<asp:TextBox ID="txtLoginPass" runat="server" BorderStyle="None" BorderWidth="0px" TextMode="Password" Wrap="False"></asp:TextBox>
<asp:Button ID="btnLogin" runat="server" BorderStyle="None" OnClick="Button1_Click" Text="Login" />
</p>
<p>
<asp:Label ID="lblRegister" runat="server" Font-Bold="True" Font-Underline="True" ForeColor="#0000CC" Text="Register"></asp:Label>
<asp:Label ID="lblLoggedIn" runat="server"></asp:Label>
</p>
<p>
</p>
</div>
</section>
<div class="navigation-bar">
<ul class="navigation-menu">
<li><a href="#" class="home">Home</a></li>
<li><a href="#" class="mainsettings">Settings</a></li>
<li><a href="#" class="profile">Profile</a>
<ul>
<li><a href="#" class="messages">Messages</a></li>
<li><a href="#" class="settings">Profile Settings</a></li>
</ul>
</li>
<li><a href="#" class="uploads">Uploads</a></li>
<li><a href="#" class="documents">Media</a>
<ul>
<li><a href="#" class="docs">Documents</a></li>
<li><a href="#" class="others">Others</a></li>
</ul>
</li>
<li><a href="#" class="projects">Projects</a>
<ul>
<li><a href="#" class="yprojects">Your Projects</a></li>
<li><a href="#" class="otherprojects">Other Projects</a></li>
</ul>
</li>
</ul>
</div>
<section id="middle">
<div id="container">
<div id="content">
<div>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</div>
</div>
</section>
<footer id="footer">
<strong>Footer:</strong> adsfdsgfds
</footer>
</div>
</form>
</body>
</html>
Protected Sub btnProjSettings_Click(sender As Object, e As EventArgs) Handles btnProjSettings.Click
Dim conn2 As New SqlConnection("Data Source=BRIAN-PC\SQLEXPRESS;Initial Catalog=master_db;Integrated Security=True")
Dim sqlComm2 As String = "SELECT project_id FROM projects WHERE project_name=@projectname"
Dim sqlProjID As New SqlCommand
conn2.Open()
sqlProjID = New SqlCommand(sqlComm2, conn2)
sqlProjID.Parameters.AddWithValue("@projectname", drpProjects.SelectedItem.Text)
Dim datareader As SqlDataReader = sqlProjID.ExecuteReader()
datareader.Read()
If datareader.HasRows Then
Dim UserID As String
UserID = datareader("project_id").ToString
Session("project_id") = UserID
Server.Transfer("Project.aspx", True)
End If
datareader.Close()
conn2.Close()
End Sub
最佳答案
我相信您遇到的问题与在异步回发期间尝试重定向到另一个页面有关。
在您的 btnProjSettings_Click
事件处理程序,替换:
Server.Transfer("Project.aspx", True)
Dim jsRedirect As String = "window.location.pathname = 'Project.aspx';"
ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "Redirect to Project.aspx", jsRedirect, true)
Server.Transfer
,服务器会返回指定页面的HTML代码;因此您看到的错误。
关于asp.net - 将 session 变量传递给 SQLDataSource 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15824407/
是否为每个 Shiny session 分配了 session ID/ session key (如果部署在 Shiny 服务器上)?如果是,我如何访问该信息?我已阅读文档here然而上网查了一下,并
我正在使用 this koajs session 模块。 我检查了源代码,但我真的无法理解。 我想知道它保存 session 数据的位置,因为我没有看到创建的文件,并且当服务器重新启动时, sessi
实现高可扩展性的一种方法是使用网络负载平衡在多个服务器之间分配处理负载。 这种方法提出的一个挑战是服务器是否具有状态意识 - 将用户状态存储在“ session ”中。 此问题的一个解决方案是“粘性
在负载平衡服务器的上下文中, session 亲和性和粘性 session 之间有什么区别? 最佳答案 我见过这些术语可以互换使用,但有不同的实现方式: 在第一个响应中发送 cookie,然后在后续响
我希望其他人向我解释哪种方法更好:使用 session 或设计无 session 。我们正在开始开发一个新的 Web 应用程序,但尚未决定要遵循什么路径。 无 session 设计在我看来更可取: 优
现在用户在他的权限中有很多角色,我将允许他点击 href 并在新窗口中扮演另一个角色。每个角色都有自己的 session 。 既然浏览器打开窗口不能用新 session 打开,我必须在服务器端想办法。
我正在尝试为express.js Node 应用程序实现 session 存储我的问题是: 如何删除具有浏览器 session 生命周期的 cookie(根据连接文档标记有 expires = fal
在开始在 golang 中使用 session 之前,我需要回答一些问题 session 示例 import "github.com/gorilla/sessions" var store = ses
我读过 Namespaced Attributes . 我尝试使用此功能: #src/Controller/CartController.php public function addProduct(
我正在努力完成以下工作: 根据用户的类型更改用户的 session cookie 到期日期。 我有一个 CakePHP Web 应用程序,其中我使用 CakePHP session 创建了我的身份验证
这是我在这里的第一个问题,我希望我做对了。 我需要处理一个 Java EE 项目,所以在开始之前,我会尝试做一些简单的事情,看看我是否能做到。 我坚持使用有状态 session Bean。 这是问题:
ColdFusion session 与 J2EE session 相比有什么优势吗? ColdFusion session documentation提到了 J2EE session 的优点,但没有
在执行任何任务之前,我需要准确地在创建 session 时创建一个 session 范围变量(因为我的所有任务都需要一个初始 session 范围变量才能运行)。因为,创建 session 时,gra
我们当前的应用使用 HTTP session ,我们希望将其替换为 JWT。 该设置仅允许每个用户进行一次 session 。这意味着: 用户在设备 1 上登录 用户已在设备 1 上登录(已创建新 s
很难说出这里问的是什么。这个问题是含糊的、模糊的、不完整的、过于宽泛的或修辞性的,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开它,visit the help center 。 已关
假设我在两个或更多设备上打开了两个或更多用户 session (同一用户没有管理员权限)。 在当前 session 中,如果我注销,是否意味着所有其他 session 也会关闭?如果没有,有没有办法通
我正在评估在 tomcat 中使用带有 session 复制的粘性 session 的情况。根据我的初步评估,我认为如果我们启用 session 复制,那么在一个 tomcat 节点中启动的 sess
我开始使用 golang 和 Angular2 构建一个常规的网络应用程序,最重要的是我试图在 auth0.com 的帮助下保护我的登录.我从 here 下载快速入门代码并尝试运行代码,它运行了一段时
我在 Spring Controller 中有一个方法,它接受两个相同类型的参数其中一个来自 session ,另一个来自表单提交(UI)。 问题是在 Controller 方法中我的非 sessio
在我登录之前,我可以点击我的安全约束目录之外的任何内容。如果我尝试转到安全约束目录内的某个位置,它会将我重定向到表单登录页面。如您所料。 登录后,我可以继续我的业务,并访问我的安全约束内外的资源。
我是一名优秀的程序员,十分优秀!