recently added a LoginView to an existing page, it now looks like
this:
<%@ Page Language="C#" MasterPageFile= "~/Site.master"
AutoEventWireup ="true" CodeFile="AtPre ss.aspx.cs" Inherits="AtPre ss"
Title="Calendar s Marked As 'At Press'" %>
<asp:Content ID="Content1" ContentPlaceHol derID="MainCont ent"
Runat="Server">
<asp:LoginVie w ID="LoginView1 " runat="server">
<RoleGroups>
<asp:RoleGrou p Roles="Administ rators,Printers ">
<ContentTemplat e>
<script type="text/javascript"
language="javas cript">
function SelectAllCheckb oxes(spanChk){
// Added as ASPX uses SPAN for checkbox
var oItem = spanChk.childre n;
var
theBox=(spanChk .type=="checkbo x")?spanChk:spa nChk.children.i tem[0];
xState=theBox.c hecked;
elm=theBox.form .elements;
for(i=0;i<elm.l ength;i++)
if(elm[i].type=="checkbo x" &&
elm[i].id!=theBox.id)
{
//elm[i].click();
if(elm[i].checked!=xStat e)
elm[i].click();
//elm[i].checked=xState ;
}
}
</script>
<strong><span style="font-size: 14pt"><span
style="font-size: 24pt">Calendars Currently Marked As 'At
Press':</span>
<br /><br />
Click checkbox at top of list to select all
items.</span></strong><br />
<asp:GridView ID="GridView1" runat="server"
DataSourceID="C alendarsDataSou rce" AutoGenerateCol umns="False"
DataKeyNames="p k_calendarID">
<Columns>
<asp:BoundFie ld DataField="barc ode"
HeaderText="Bar code" SortExpression= "barcode" />
<asp:BoundFie ld DataField="rece ived"
HeaderText="Rec eived" SortExpression= "received" />
<asp:BoundFie ld DataField="atpr ess"
HeaderText="At Press" SortExpression= "atpress" />
<asp:TemplateFi eld>
<ItemTemplate >
<asp:CheckBox
ID="SelectCalen darCheckbox" runat="server" />
</ItemTemplate>
<HeaderTemplate >
<input id="chkAll"
onclick="javasc ript:SelectAllC heckboxes(this) ;" runat="server"
type="checkbox" />
</HeaderTemplate>
</asp:TemplateFie ld>
</Columns>
</asp:GridView>
<br />
<asp:Button ID="btnToHandFi nishing" runat="server"
Text="Move To 'At Hand Finishing' Status"
OnClick="btnToH andFinishing_Cl ick" /><br />
<asp:ObjectData Source ID="CalendarsDa taSource"
runat="server" SelectMethod="G etCalendarsBySt atusID"
TypeName="Calen darsBLL" OldValuesParame terFormatString ="original_{0}" >
<SelectParamete rs>
<asp:Paramete r DefaultValue="2 "
Name="statusID" Type="Int32" />
</SelectParameter s>
</asp:ObjectDataS ource>
</ContentTemplate >
</asp:RoleGroup>
<asp:RoleGrou p Roles="Finisher s">
<ContentTemplat e>
You Are Not Authorized To View This Page!
</ContentTemplate >
</asp:RoleGroup>
</RoleGroups>
</asp:LoginView>
</asp:Content>
And my code-behind page looks like this:
using System;
using System.Data;
using System.Configur ation;
using System.Collecti ons;
using System.IO;
using System.Web;
using System.Web.Secu rity;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Web.UI.W ebControls.WebP arts;
using System.Web.UI.H tmlControls;
using KodakTableAdapt ers;
public partial class AtPress : System.Web.UI.P age
{
public CalendarsBLL methods = new CalendarsBLL();
protected void Page_Load(objec t sender, EventArgs e)
{
GridView1.Sort( "received", SortDirection.A scending);
}
protected void btnToHandFinish ing_Click(objec t sender, EventArgs e)
{
//Use this method to copy the items in the
GridViewRowColl ection object
//into the specified System.Array object, starting at the
specified index.
//The System.Array object can then be used to access the items
in the collection.
// Copy the items in the Rows collection into an array.
GridViewRow[] rowArray = new GridViewRow[GridView1.Rows. Count];
GridView1.Rows. CopyTo(rowArray , 0);
DataKey key;
// Iterate though the array and display the value in the first
cell of the row.
foreach (GridViewRow row in rowArray)
{
bool result =
((CheckBox)row. FindControl("Se lectCalendarChe ckbox")).Checke d;
if (result)
{
byte fk_statusID = 3;
DateTime athandfinishing = DateTime.Now;
key = GridView1.DataK eys[row.RowIndex];
int pk_calendarID = ((int)key.Value );
// Get filename
string filename =
methods.GetCale ndarFilename(pk _calendarID);
methods.UpdateC alendarAtHandFi nishing(fk_stat usID,
athandfinishing , pk_calendarID);
// Move Files to "READY_TO_PRINT " folder
string from = "C:\\HTTPPush\\ READY_TO_PRINT\ \" +
filename;
string to = "C:\\HTTPPush\\ PROCESSED\\" + filename;
File.Move(from, to);
// Response.Redire ct("~/AtHandFinishing .aspx");
}
}
GridView1.DataB ind();
}
}
And I get the following error:
Compilation Error
Description: An error occurred during the compilation of a resource
required to service this request. Please review the following specific
error details and modify your source code appropriately.
Compiler Error Message: CS0103: The name 'GridView1' does not exist in
the current context
Source Error:
Line 17: protected void Page_Load(objec t sender, EventArgs e)
Line 18: {
Line 19: GridView1.Sort( "received", SortDirection.A scending);
Line 20: }
Line 21: protected void btnToHandFinish ing_Click(objec t sender,
EventArgs e)
I'm assuming this is due to the GridView not showing for the "current"
user. However, even if I add an if (GridView1) before the
GridView1.Sort it still fails. How can I test to see if GridView1
exists, and if so then execute the code...otherwis e ignore the code.
I'm sure there's a simple answer, that I should probably know, but I
can't seem to come up with it. Thanks in advance for any help!
-Sean 0 1906 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: RedEye |
last post by:
Hello,
I have been looking for a way to add roles to a LoginView control
programmatically and it's not working. I have called the sub at init and
load and neither work. Does anyone know what I may be over looking?
Thanks for any help
Private Sub AddRoles()
Dim rg As New RoleGroup
|
by: ad |
last post by:
I use a LoginView to authenticate user.
Can we set the focus in the UserName or Password of the LoginView?
|
by: Casey |
last post by:
Hello.
I'm using the loginview control. There are 2 default templates. The
'LoggedInTemplate', and the 'anonymoustemplate'. However, I also have a
template (or view?) for the admin role. How do I access the content
dynamically within the loginview for the admin role?
I tried placing a label within the control, and then tried accessing the
control, but I cannot (I'm assuming it's becuase it a control within a
control), but if I do a...
|
by: keithb |
last post by:
Using Website | ASP.NET Configuration, I set up a role name Administrators
and a user named admin. In my application, I put a LoginView Conrol on my
master page. The LoginView control has an anonymous Template, and a
<RoleGroup> with Roles = "Administrators"
The login accepts the credentials of admin when they are entered correctly;
however the status of the LoginView conrol continues to say "You are not
logged in." Can someone...
|
by: Phil |
last post by:
I have gridview with a templatefield in which is a loginview. The loginview
displays a delete linkbutton for a specified group only. when a record is
delete the loginview displays the contents of the rolegroup, but the Eval
function in the loginview no longer works (it still works in the
itemtemplate, just not the loginview portion). Any text or non-databound
controls in the contenttemplate still render, but the Eval function doesn't...
| |
by: pagates |
last post by:
Hello All,
Is there a way to show common "stuff" in the LoginView for all logged in
users when using <RoleGroups>?
In other words, I have a number of links that all users that log in should
see. There are additional links special to particular roles. It appears
that I need to do something like (plus usual parameters like runat="server"):
<asp:LoginView>
|
by: =?Utf-8?B?am1obWFpbmU=?= |
last post by:
When I put asp controls inside the LoginView it removes the codebehind
references so that the page will not build. For example:
<asp:LoginView ID="LoginView" runat="server" >
<LoggedInTemplate>
<asp:LoginName id="loginName" runat="server" FormatString="You
are logged in as: {0} | " />
<asp:LoginStatus id="loginStatus" runat="server"
LogoutText="logoff" />
<br />
<asp:Label ID="pageContentIsAuth" runat="server" >
|
by: Morgan Cheng |
last post by:
I tried to add a LoginView control in OnClick eventhandler of a
button.
The code is like below
LoginView login = new LoginView();
PlaceHolder1.Controls.Add(login);
After run the page, I click the button and nothing happens.
If I change LoginView to a Label, it shows.
|
by: Jeff |
last post by:
Hey
ASP.NET 2.0
I'm about to start programming a new website at work. My boss want's me
avoid using the Membership system in ASP.NET 2.0 (probably because he don't
understand how it works...)...
Well the users will be devided into 2 categories. Normal user and
Administrators
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |