我正在创建一个cookie并在成功登录后存储用户名的值.如何在网站打开时访问cookie.如果cookie存在,我想填写cookie值的用户名文本框.以及如何解密该值以获取用户名.我通过从数据库获取用户详细信息来进行服务器端验证.我正在使用vs 2010与c#
FormsAuthenticationTicket tkt;
string cookiestr;
HttpCookie ck;
tkt = new FormsAuthenticationTicket(1, txtUserName.Value, DateTime.Now,
DateTime.Now.AddYears(1), chk_Rememberme.Checked, "User Email");
cookiestr = FormsAuthentication.Encrypt(tkt);
ck = new HttpCookie(FormsAuthentication.FormsCookieName, cookiestr);
if (chk_Rememberme.Checked)
{
ck.Expires = tkt.Expiration;
ck.Path = FormsAuthentication.FormsCookiePath;
Response.Cookies.Add(ck);
}
Run Code Online (Sandbox Code Playgroud)
创建cookie,名称为.YAFNET_Authentication,内容已加密
Webconfig:
<forms name=".YAFNET_Authentication" loginUrl="Home.aspx"
protection="All" timeout="15000" cookieless="UseCookies"/>
Run Code Online (Sandbox Code Playgroud) 我已将文件上传添加到我的asp.net网站.但是,我想限制用户可以选择的文件类型.例如,我只有用户选择mp3文件.如何在文件上传中添加过滤器,以便仅显示所选文件夹中的mp3文件?
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="btnAudUpload" Text="Upload" CssClass="btncssUpload" OnClick="btnAudUpload_Click" runat="server" />
Run Code Online (Sandbox Code Playgroud) <asp:GridView ID="Grid_Organisationtable" runat="server" CssClass="string"
SelectedIndex="0" DataKeyNames="OrganisationID"
ShowHeaderWhenEmpty="True" OnRowDeleting="Grid_Organisationtable_RowDeleting" OnRowEditing="Grid_Organisationtable_RowEditing"
AutoGenerateColumns="false" Height="95px" Width="492px">
<Columns>
<asp:TemplateField HeaderText="Edit Controls" ItemStyle-Width="15%">
<ItemTemplate>
<asp:ImageButton ImageUrl="~/Styles/Images/Edit.jpg" CommandName="Edit" runat="server"
ID="btn_Edit" ToolTip="Edit Organisation" />
<asp:LinkButton ID="LinkButton1" CommandArgument='<%# Eval("OrganisationID") %>' CommandName="Delete" runat="server">delete</asp:LinkButton>
</ItemTemplate>
<ItemStyle Width="15%" />
</asp:TemplateField>
Run Code Online (Sandbox Code Playgroud)
我在网格视图中有一个链接按钮从网格中删除一行,我想将图像添加到链接按钮而不是文本删除.如何将图像添加到链接按钮.我不想使用图像按钮.谢谢.
我正在进行查询以从tbl_message表中获取Title和RespondBY,我想在对数据绑定到转发器之前解密Title.如何在执行数据绑定之前访问标题值.
string MysqlStatement = "SELECT Title, RespondBy FROM tbl_message WHERE tbl_message.MsgID = @MsgID";
using (DataServer server = new DataServer())
{
MySqlParameter[] param = new MySqlParameter[1];
param[0] = new MySqlParameter("@MsgID", MySqlDbType.Int32);
param[0].Value = MessageID;
command.Parameters.AddWithValue("@MsgID", MessageID);
ds = server.ExecuteQuery(CommandType.Text, MysqlStatement, param);
}
rptList.DataSource = ds;
rptList.DataBind();
<table style="width: 498px; color: #F5F5F5;">
<asp:Repeater ID="rptList" runat="server">
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td width="15%">
<b>Subject</b>
</td>
<td width="60%">
<asp:Label ID="lbl_Subj" runat="server" Text='<%#Eval("Title")%>' />
</td>
</tr>
Run Code Online (Sandbox Code Playgroud) <script type="text/javascript">
$(function () {
$('.datePicker').datetimepicker({ dateFormat: 'dd/mm/yy' });
});
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:TextBox ID="TextBox1" class="datePicker" runat="server"></asp:TextBox>
<asp:UpdatePanel ID="holder" runat="server" UpdateMode="Always" ChildrenAsTriggers="true">
<ContentTemplate>
<asp:DropDownList runat="server" ID="ddl_RespondBy" AutoPostBack="true" OnSelectedIndexChanged="ddl_SelectedIndexChanged">
<asp:ListItem Selected="True">1 Hour</asp:ListItem>
<asp:ListItem>Other</asp:ListItem>
</asp:DropDownList>
<asp:TextBox ID="txt_RespondBy" class="datePicker" Visible="true" runat="server" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddl_RespondBy" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
</asp:Content>
protected void ddl_SelectedIndexChanged(object sender, EventArgs e)
{
if (ddl_RespondBy.SelectedItem.Text == "Other")
{
txt_RespondBy.Visible = true;
}
else
{
}
}
Run Code Online (Sandbox Code Playgroud)
我使用更新面板进行部分回发,我有两个文本框,一个在更新面板外面,一个在内部,当我从下拉列表中选择其他内容并尝试打开txt_RespondBy文本框内的日历时它没有显示,但是文本框外部更新面板显示日历.为什么Javascript在部分回发后无法在更新面板内工作
int topID = 0;
string TopIDQuery = "Select TopID from tbl_Organisation where OrganisationID=@OrgID";
paramet[0] = new MySqlParameter("@OrgID", MySqlDbType.Int32);
paramet[0].Value = OrgID;
reader = server.ExecuteReader(CommandType.Text, TopIDQuery, paramet);
while (reader.Read())
{
topID = Convert.ToInt32(reader["TopID"]);
}
reader.Close();
Run Code Online (Sandbox Code Playgroud)
我正在topID从表中读取,当TopID为null时,我想保留topID为0,但由于它为null,因此抛出错误,如何在topIDnull 时处理此错误
<asp:CheckBoxList ID="ckl_EditRole" DataValueField="RoleName" runat="server">
</asp:CheckBoxList>
public void BindListBoxPermission(int field)
{
MySqlCommand command = new MySqlCommand();
DataSet ds = new DataSet();
int newOrgID = field;
string MysqlStatement = "SELECT RoleName from tbl_Role Where RoleID >1 order by RoleID desc";
MySqlParameter[] param = new MySqlParameter[0];
ds = server.ExecuteQuery(CommandType.Text, MysqlStatement, param);
ckl_EditRole.DataSource = ds;
ckl_EditRole.DataBind();
}
Run Code Online (Sandbox Code Playgroud)
对于每个项目,工具提示是不同的,因为管理工具提示是创建用户而对于用户工具提示是创建消息.如何为复选框内的每个项添加工具提示
UserID UserName ParentID TopID
1 abc Null Null
2 edf 1 1
3 gef 1 1
4 huj 3 1
5 jdi 4 1
6 das 2 1
7 new Null Null
8 gka 7 7
Run Code Online (Sandbox Code Playgroud)
TopID和ParentID来自userID
我想获得用户记录及其子和子记录.这里userid1是root,其子节点是userid2和userid 3.所以如果用户id是1,我必须显示从userid 1到userid 6的所有记录,因为所有记录都是root的子节点和SUbchild.类似地,对于userid3,如果用户标识是3,我必须显示userid3及其子Userid 4和Userid用户4 Userid5
输出应该是
Userid Username
3 gef
4 huj
5 jdi
Run Code Online (Sandbox Code Playgroud)
我将了解userid和topID,以便我如何进行查询以实现上述结果.
SELECT UserID, UserName FROM tbl_User WHERE ParentID=3 OR UserID=3 And TopID=1;
Run Code Online (Sandbox Code Playgroud)
通过上面的查询,我能够显示用户ID 3和用户ID 4我无法显示用户ID 5,其中有种类.需要帮忙.谢谢
var r = {
init : function(){
r = Raphael("pie");
//r.g.txtattr.font = "12px 'Fontin Sans', Fontin-Sans, sans-serif";
r.g.text(320, -330, "Message Status").attr({ "font-size": 20 });
var pie = r.g.piechart(360, -180, 100, <%= Session["uStats"] %>, { legend: [<%= Session["vkeyColor"] %>], colors: [<%= Session["vPieColor"] %>] });
pie.hover(function () {
this.sector.stop();
this.sector.scale(1.1, 1.1, this.cx, this.cy);
if (this.label) {
this.label[0].stop();
this.label[0].scale(1.5);
this.label[1].attr({ "font-weight": 800 });
}
}, function () {
this.sector.animate({ scale: [1, 1, this.cx, this.cy] }, 500, "bounce");
if (this.label) {
this.label[0].animate({ scale: 1 …Run Code Online (Sandbox Code Playgroud) 我有一个文本编辑器,在将格式应用于文本后,我会在单击按钮时显示文本.我希望文本显示在文本编辑器中应用的所有格式.
lbl_Subject.Text = Server.HtmlEncode(formattedtext);
Run Code Online (Sandbox Code Playgroud)
但它不会以应用的格式显示,而是显示为
<p> This is Para 1</p> <p> this is Para 2</p> <p> <strong>this is bold</strong></p>
Run Code Online (Sandbox Code Playgroud)
如何显示文本编辑器中应用的所有格式的文本
更新我试用文字
结果是
<p> This is Para 1</p> <p> this is Para 2</p> <p> <strong>this is bold</strong></p>
Run Code Online (Sandbox Code Playgroud) asp.net ×8
c# ×8
javascript ×2
jquery ×2
checkboxlist ×1
cookies ×1
dataset ×1
file-upload ×1
hierarchy ×1
html ×1
mysql ×1
null ×1
parent-child ×1
sql ×1
text-editor ×1
tooltip ×1
updatepanel ×1