problem with e.Row.Cells() of gridview
Hi,
i want to make the forecolor of values into a gridview red but only when
they equals 'n'.
<asp:GridView ID="GridView1" runat="server"
DataKeyNames="hour,place" DataSourceID="SqlDataSource1" >
<Columns>
<asp:CommandField ShowEditButton="True"/>
<asp:BoundField DataField="place" HeaderText="place"
ReadOnly="True" />
<asp:BoundField DataField="hour" HeaderText="hour"
ReadOnly="True" />
<asp:TemplateField HeaderText="theday">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1" SelectedValue='<%#
Bind("theday") %>' runat="server">
<asp:ListItem Text="y" Value="y"></asp:ListItem>
<asp:ListItem Text="n" Value="n"></asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("theday")
%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs) Handles
GridView1.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim m As String
m = e.Row.Cells(3).Text
If m = "n" Then
e.Row.Cells(3).ForeColor = Drawing.Color.Red
End If
End If
End Sub
The values are correctly rendered, i can update etc ... but the forecolor
remains black. Is this due to the template?
Thanks for help
Chris Tag: authenticating to domain Tag: 516103
javascript file won't work with .cs file...
Hello. I'm reposting this because my prioe post's subject line was
incorrect.
I'm developing an asp.net 2.0 project using VS 2005 on XP sp2 with all
the updates. I have an aspx page with javascript that works fine until I
try to separate the script into a .js file. I've found that only the script
that is called from events set in the aspx.cs file don't work. I eliminated
all script except two functions. One is used with the .cs file and the
other one is not.
First, here's the functino used with the .cs file:
if (!this.IsPostBack)
{
btnFirst.OnClientClick = "return btnFirst_Click()";
}
... the javascript function is...
function btnFirst_Click()
{
alert("This is btnFirst_Click"):
return false;
}
Now the second javascript function is only
function ShowAlert()
{
alert("This is ShowAlert");
return false;
}
This function is called from another button - button1 - from the
OnClientClick event which I set in the property page..
When I have all the javascript in the aspx page, it all wokrs, but when I
move it to a .js file, the first function doesn't work, but the second one
does.
I don't want to add all my javascript in rhe .cs file because that would
expose all my code - that's why I'm teying to put it in a .js file.
How can I make all the code work using both methods?
Thanks...
--
Matthew.Wells
Matthew.Wells@FirstByte.net Tag: authenticating to domain Tag: 516101
how make codefile default
Usually I like to have my vb code in a seperate file, rather than inline
with the HTML. I know that the codefile directive is what links the 2
together.
For some reason, all of a sudden my new pages are lacking the CodeFile even
though I check "Place code in separate file". Is it because they are linked
with a master page? How can I do this after the fact?
Thanks. Tag: authenticating to domain Tag: 516100
Thread.CurrentPrincipal.Identity.Name returns "ANONYMOUS LOGON"
Hi,
I have a .NET 2 Remoting client in an ASP application, pages call various
methods on the TCP channel. The .NET Remoting Server runs as a Windows
Service, "secure"=true in both the Client and Server Remoting interfaces..
But when I call Thread.Current.Principal.Name in the server, it always
returns "NT AUTHORITY\\ANONYMOUS LOGIN".
How can I get the ID of the user that is logged into the ASP application ?
Thanks, B Tag: authenticating to domain Tag: 516094
Encrypting Webconfig file values in .Net 1.1 Framework
Hi,
Could anyone suggest me an idea to encrypt the webconfig file's connection
string in the framework 1.1.
Thank you in Advance
--
Lets Learn and Make All Learn Tag: authenticating to domain Tag: 516093
Source code for web applications
Is it possible for an ASP.net server (like IIS 6) to run web application
without having available the code behind forms in clear ascii? Can I provide
a compiled product to the customer, not an exe file of course, but some dll
compiled by my server ?
I'm asking that because 1. sometimes I am not happy to provide my source
code 2.customer is afraid of their internal security...
Thanks
Max Tag: authenticating to domain Tag: 516092
Could not load file or assembly System.Data.Entity
I am recieving the following. This happens when I moved it from my
development system to our production SBS 2003 w/ latest .net frameworks and
service packs . I developed under XPSP2 and VS2008.
The error is pointing to the Web.Config of my application.
System.Data.Entity was missing from the server, but was on the dev system.
I tried to add, but didnt help:
C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5
Server Error in '/' Application.
--------------------------------------------------------------------------------
Configuration Error Description: An error occurred during the processing of
a configuration file required to service this request. Please review the
specific error details below and modify your configuration file
appropriately.
Parser Error Message: Could not load file or assembly 'System.Data.Entity,
Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of
its dependencies. The system cannot find the file specified.
Source Error:
Line 47: <add assembly="System.Xml.Linq, Version=3.5.0.0,
Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
Line 48: <add assembly="System.Security, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
Line 49: <add assembly="System.Data.Entity, Version=3.5.0.0,
Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
Line 50: <add assembly="System.Data.Entity.Design, Version=3.5.0.0,
Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
Line 51: <add assembly="System.Data.Linq, Version=3.5.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
Source File: D:\Inetpub\wwwroot\GoldmineIntegration\web.config Line: 49
Assembly Load Trace: The following information can be helpful to determine
why the assembly 'System.Data.Entity, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089' could not be loaded.
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value
[HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind
failure logging.
To turn this feature off, remove the registry value
[HKLM\Software\Microsoft\Fusion!EnableLog].
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.1433;
ASP.NET Version:2.0.50727.1433 Tag: authenticating to domain Tag: 516090
Javascript file won't work with RegisterClientScript
Hello,
I'm developing an asp.net 2.0 project using VS 2005 on XP sp2 with all
the updates. I have an aspx page with javascript that works fine until I
try to separate the script into a .js file. I've found that only the script
that is called from events set in the aspx.cs file don't work. I eliminated
all script except two functions. One is used with the .cs file and the
other one is not.
First, here's the functino used with the .cs file:
if (!this.IsPostBack)
{
btnFirst.OnClientClick = "return btnFirst_Click()";
}
... the javascript function is...
function btnFirst_Click()
{
alert("This is btnFirst_Click"):
return false;
}
Now the second javascript function is only
function ShowAlert()
{
alert("This is ShowAlert");
return false;
}
This function is called from another button - button1 - from the
OnClientClick event which I set in the property page..
When I have all the javascript in the aspx page, it all wokrs, but when I
move it to a .js file, the first function doesn't work, but the second one
does.
I don't want to add all my javascript in rhe .cs file because that would
expose all my code - that's why I'm teying to put it in a .js file.
How can I make all the code work using both methods?
Thanks.
--
Matthew.Wells
Matthew.Wells@FirstByte.net Tag: authenticating to domain Tag: 516084
how does one limit postback to a small section of screen?
I have a checkbox on my webpage which, if checked, should cause a
textbox to be enabled (or made visible). But I find I need to make
the checkbox have a autopostback of TRUE for this to work. Is there
any way, perhaps using Ajax update panels, to have a checkbox cause a
partial postback of only part of the page?
Thanks,
Marvin Tag: authenticating to domain Tag: 516074
Silverlight newsgroup?
Is there a place to request a new newsgroup?
..
Or does anyone know if the Forum model is better for silverlight?
http://silverlight.net/forums/
Just wondering. Tag: authenticating to domain Tag: 516073
Use class ... why is not available?
Hello,
I am working with VS 2008 and created a Web Application Project.
I added a class but whatever I do the class is not visible to my aspx
pages or anywhere else.
I then changed the property Build Action in my class from Content to
Compile. Now it is recognized.
Why do I need to do this?
Do I need to do this with all classes I create?
Thanks,
Miguel Tag: authenticating to domain Tag: 516064
KeyBoard Layout
Currenlty I am working on KeyBoarLayout in C#. I donot know how to
change the keyboardlayout .I am creating a software similar to "Avro
KeyBoard 4.5.1". Thanks in advance.
Arnab Tag: authenticating to domain Tag: 516060
Use library
Hello,
In a web site application in VS 2008 where should I place third party
DLL files and what is the best way to make them available, including
the namespaces, to my web application?
Thanks,
Miguel Tag: authenticating to domain Tag: 516059
UTF-8
Hi,
I'm uploading a text file (.csv) dynamically to the client with this method
:
--
Response.Clear();
Response.AddHeader("Content-disposition:", "attachment;
filename=export.csv");
Response.AddHeader("Content-type", "application/vnd.ms-excel");
Response.ContentEncoding = Encoding.UTF8;
Response.Write([...]);
Response.Write([...]);
Response.End();
--
Some accentuated acharacters does not display correctly in excel... but when
I open the file the characters are displayed fine.. and notepad tells me
that the file is indeed a UTF-8 file (when file/save as)..
Im I missing something here? (apparently yes!)
Thanks guys (and or gals)
Mike Tag: authenticating to domain Tag: 516057
Getting the DataKey Value in a GridView
I have a gridview that has a label field and a checkbox field in it. I have
the checkbox set to autopost when changed. How can I get the datakey value
that is assigned to that row when a checkbox is either checked or unchecked? Tag: authenticating to domain Tag: 516056
MS Design template installation problem
Hi!
I have downloaded and installed the design templates Personal Design
and Basic from http://msdn.microsoft.com/en-us/asp.net/aa336613.aspx
but I cannot make them appear among other templates when choosing "New
project"
I have also installed other templates like these:
http://www.visualwebgui.com/Community/Resources/Codes/tabid/326/articleType/ArticleView/articleId/45/Default.aspx
and that works, they are visible under My Templates in the New project
- wizard.
What shall I do to be able to select the MS-templates?
Thanks! Tag: authenticating to domain Tag: 516053
FormViewList?
Hi,
I like FormView for its flexibility. Is there something for displaying
list of FormViews? If not what is the best way to show dynamic number
of FormViews?
Thanks in advance,
Etam. Tag: authenticating to domain Tag: 516045
Help: Copy Web site vs Publish Website vs Web Deployment Project
When would I use "Copy Web site" over "Publish Website" or visa versa? Why
would I use the Web Deployment Project vs these options?
I want to make sure no one can pull up/read/download my vb source code (in
.vb files).
I would prefer easy update of the site (code or aspx.)
Thanks. Tag: authenticating to domain Tag: 516044
How to display a Wait page while a query is running?
If I am running a long time query, how to show a wait page at then? Is there
any recommended way to do it? Thanks. Tag: authenticating to domain Tag: 516035
RedirectFromLoginPage redirect to a Different URL
Dear All,
RedirectFromLoginPage will always re-direct to the ReturnURL or
DefaultURL. And unfortunately neither one of this can be changed
programmatically.
I have a need, where different users need to be re-directed to
different page after login.
How can I do that?
Thanks in advance. Tag: authenticating to domain Tag: 516034
Output Caching with Custom HTTP Handler
I'm creating a custom handler that does not extend Page (only implements
IHttpHandler) - and I would like for its output to be cached to improve
runtime performance. I would like to leverage ASP.NET's output caching
capabilities that are already in place for standard Page requests. How can I
leverage the existing output caching mechanisms with my custom HTTP handler?
I'd like the standard output caching options to be available, if possible
(options like sliding expiration, etc).
Thanks. Tag: authenticating to domain Tag: 516032
Type not Defined. Going crazy!
Hello,
On an ASP.NET 3.5 web site App_Code folder I have a class named
BoxesView under the namespace Engine.
On an aspx page code behind I have the following:
Protected WithEvents c As New Engine.BoxesView
Then I added it to the page. BoxesView inherits composite control.
I don't get any error when I write my code. However when I build the
web site I sometimes get the following error:
Compiler Error Message: BC30002: Type 'BoxesView' is not defined.
Sometimes the page runs fine sometimes I get the error.
I don't make any changes ... I have no idea why this is happening!
I am on this for 2 hours.
Why does my page either runs or display an error?
And why I don't get any error in my code but only when sometimes when
I run my page or build the web site?
I am using VS 2008.
Thanks,
Miguel Tag: authenticating to domain Tag: 516027
Displaying HTML Docs on a WebPage
I have HTML formatted documents stored in a database. I want to display
them on a web page. However I see there is no "browser control" in asp (as
there is in windows forms). This sounds kind of stupid but is there a
control that I can load HTML into to display in a web page?
Thanks,
Gary Tag: authenticating to domain Tag: 516024
SiteMap and security trimming problems
Hi,
I have security trimming enabled in web.config and the following site map
attached to a menu:
<siteMapNode roles="*" url="~/Default.aspx" title="Home" description="">
[...]
<siteMapNode roles="Administrators,Managers" title="Admin">
<siteMapNode roles="Administrators" url="~/Admin/AdminOnly.aspx"
title="Admin Only"/>
<siteMapNode roles="Administrators,Managers"
url="~/Admin/AdminAndManager.aspx" title="Admin and Manager" />
</siteMapNode>
[...]
</siteMapNode>
If I login as a user without Administrators and Managers roles then I cannot
seem "Admin", which is expected. When I login as a user with Adminstrators
role then I can see all items in the menu, which is also expected. But,
when I login as a user with Managers role only then I can still see all menu
items. I thought that "AdminOnly.aspx" node would not be available to
Managers but this is not the case.
Am I missing something obvious here?
I'd appreciate any suggestions.
Thanks,
Bogdan Tag: authenticating to domain Tag: 516023
Citrix "The Page cannot be displayed"
I have the following code which works fine in IE6 and IE7 and FireFox, but
when I run IE6 on Citrix I get "The page cannot be displayed" in the iframe.
We don't have IE7 on Citrix so I can't try it.
<span id="ShowReport" disabled="disabled"
style="display:inline-block;height:1200px;width:880px;">
<div>
<iframe src=../../WsiLogo.gif> <frame src=../../WsiLogo.gif>
<embed src=../../WsiLogo.gif> </iframe>
</div>
</span>
I know little about Citrix and our Citrix admin knows little about HTML, so
between two of us we know nothing.
Does anyone have any suggestions on how to fix this?
Thank You
Peter Tag: authenticating to domain Tag: 516012
Usage of '/' in .aspx page url
I was just browsing through Dell's website and saw usage of '/' after
the aspx page name(productdetails.aspx) in the url. e.g.:-
http://www.dell.com/content/products/productdetails.aspx/inspnnb_1720?c=us&cs=19&l=en&s=dhs&~ck=mn
I am only familiar with usage of the query strings using the following
format:-
'.../pagename.aspx?
<queryStringVariable1>=<Value1>&<queryStringVariable2>=<Value2>...'
Any idea about the usage of the former type? Does it has any specific
advantages?
Thanks in advance for the response. Tag: authenticating to domain Tag: 516010
sql problem with updating data from a gridview
Hi,
i defined a gridview and a sqldatasource with following commands: (two
tables 'tableA' and 'tableB' are linked with field 'heure')
SelectCommand="SELECT tableA.mday, tableB.range FROM tableB INNER JOIN
tableA ON tableB.heure = tableA.heure"
UpdateCommand="UPDATE tableB INNER JOIN tableA ON tableB.heure =
tableA.heure SET tableA.mday = @mday
WHERE tableB.range = @range"
the select command is ok.
i tested the update command with MS Access and it works.
With asp.net/sql server, it gives an error: Incorrect syntax near the
keyword 'FROM'.
Could anybody tell me the right syntax?
Thanks
Chris Tag: authenticating to domain Tag: 516008
How to Create Drill Down on Web Page
Can anyone provide any help on how I would create a drill down on a
web page? I want to create something like when you search for car
parts the user can navigate the drill downs and at the top of the page
is says something like this:
Chevy>>2002>>Avalanche>>1500
What is the database behind it? I want to use an Access Database to
store the data is that possible? How would the database be
structured?
(Using Asp.net 2.0, VB.net) Tag: authenticating to domain Tag: 516007
ASP.NET Request Pipeline and GoF Chain of Responsibility
More of a theoretical question here: It just occurred to me that the ASP.NET
request pipeline delivers much of the GoF Chain of Responsibility pattern.
What do you think? If it does not, then, why not? Tag: authenticating to domain Tag: 516006
publishing a .NET 3.5 site
I published a ASP.NET 3.5 web site to my test box and its not working. The
server has 3.5 framework installed on it, but when I load the page, its
erroring out saying:
'unable to find assembley system.linq'
Do I need to install anything else on the server? Tag: authenticating to domain Tag: 516004
Javascript Textbox border issue
I'm adding a Textbox with javascript, it works except for the border
attribute, any advive
Thanks
John
var formFld = document.createElement('input')
formFld.setAttribute('type', 'text')
formFld.setAttribute('id', txt)
formFld.value = document.getElementById(lb).innerHTML
formFld.name = txt
formFld.setAttribute('width','30')
formFld.setAttribute('border', '3px solid #FF0000') Tag: authenticating to domain Tag: 516002
The page cannot be displayed
I have several linkbuttons in my main page (default.aspx), and each of them
has a Javascript
funtion that handles the click event and launch a new web page.
Some pages are launched without any parameters (a query string)
(window.open(Admin.aspx, '', 'menubar=0,
resizable=1, scrollbars=1, left=0, top=0, width=200, height=100');), some
pages do require
parameters (window.open(CatPage.aspx?CatNo=' + catNumber + ', '',
'menubar=0, resizable=1,
scrollbars=1, left=0, top=0, width=200, height=100');)
CatNo is the parameter I refered to.
If I keep launching/closing the Admin page (admin.aspx), I keep the main
page "live."
If I just keep refreshing the main page, or launching/closing the Cat page
(CatPage.aspx), the main
page "lives" for about 15 minutes, then I get a "The page cannot be
displayed" error when launching
the Cat page or refreshing the main page.
How can I keep my main page live?
Thanks. Tag: authenticating to domain Tag: 516001
Dynamic Web Template or Master Page?
I am creating a HTML/ASP.NET website (using Expression Web and VS 2008).
When would I use a master page over a DWT? When dealing with an ASPX page
is a mater page better? Tag: authenticating to domain Tag: 516000
FileStream file name problem.
Hello,
I have a problem with file names. When I use a fileStream to allow users to
download file from a network the spaces in the file names are being replaced
with underscores. I have no statements in my code that do so. How do I solve
this problem? thank you in advance. Tag: authenticating to domain Tag: 515998
ObjectDataSource - Select - Nullable parameter
Hello,
Have an objectdatasource with a method much like this:
public SomeDataSet.MyDataTable getMyDataTable(int? pkID)
{
if (pkID == null)
return adapater.GetMyTable("ALL")
else
return adapter.GetMyTable("SING")
}
When I configure the objectdatasource I tell it to call this method
for the select. In the define parameters if I give it a value of 1, or
2, or some other integer works fine. If I tell it to use null as the
default value, at run time I get an error "Input string was not in
correct format". Any ideas anyone?
Thanks
Ray Tag: authenticating to domain Tag: 515990
Authenticate against Active Directory
I am modifying an app for a customer in ASP.Net 1.1. The app is running on a
server outside their network, yet they want to authenticate users against
their internal active directory set up (they will open the necessary ports).
So, I have a simple login page with username and password, and then I will
authenticate that credentials entered against their AD server. I am having a
real hard time figuring this out. We can't use Windows Forms Auth, so I need
to do it all manually in code.
On the System.DirectoryServices namespace I can't find what methods I need
to connect to their AD using SSL and then to authenticate the user. I've
found a lot online using Forms Auth and ADAM, but nothing has really fit
what I'm doing.
Could anyone point me to a tutorial or outline what methods, etc I need to
use to accomplish this?
Thank you so much!
Jon Tag: authenticating to domain Tag: 515989
How to float a menu on the right within a div?
Hi,
I have a div to provide a background image for a menu. I'd like to position
the menu on the right side but I can't seem to find a right way of doing it.
The only way the menu will move to the right if I set text-align=right in
the div. The problem is that menu items are then also aligned on right
side. Not only that but this alignment works only in IE.
Could someone please let me know how to right-align the menu?
Menu:
<div id="menuArea">
<asp:Menu ID="topMenu" runat="server" Orientation="Horizontal"
StaticEnableDefaultPopOutImage="false"
DataSourceID="dsSiteMap">
<StaticMenuItemStyle CssClass="staticMenu" />
</asp:Menu>
<asp:SiteMapDataSource ID="dsSiteMap" runat="server"
ShowStartingNode="False" />
</div>
CSS:
#menuArea
{
background-image: url(Images/header_menu.gif);
background-repeat: no-repeat;
clear: both;
padding-right: 10px;
padding-left: 0%;
font-weight: normal;
font-size: 0.8em;
float: none;
padding-top: 0%;
padding-bottom: 0%;
margin: 0%;
color: #477897;
width: 720;
height: 39px;
/*text-align: right;*/
}
.staticMenu
{
background-color: Transparent;
float: right;
}
Thanks,
Bogdan Tag: authenticating to domain Tag: 515988
Menu/SiteMap question - visibility
Let's say I have an ASP.Net menu, with a datasourceID of a siteMapPath,
which of course is based on a web.sitemap file
Based on the person logged into the page, I have code in files in the
App_Code folder which gets their job code, by which I need to let some
people see some things (some root nodes and sometimes it's a sub node) and
other people not see things.
However, I don't know how to refer to the Menu Items in code
As I understand it, if I built a menu item manually, it would be something
like this:
<asp:MenuItem NavigateUrl="~/Default.aspx" Text="Website Home"
Value="Home"></asp:MenuItem>
But, in the web.SiteMap file, it is something like this:
<siteMapNode title="Website Home" url="~/default.aspx" description="Website
Home"></siteMapNode>
but nothing for the 'value'.
So, if I hard coded the items, The 'Text' property in the MenuItem control,
here, matches up with the title attribute in the siteMapNode.
Therefore, I could refer to them by their value (in this case, "Home"), but
if it's based on the web.SiteMap file, there's no 'value' attribute.
Any ideas here? Tag: authenticating to domain Tag: 515987
Problem with session variables
Hello
I have an ASP.NET app (VS 2005) that requires users to login and then
presents some private information to users. The user identity is kept after
login by session variables. (cookies)
Everything goes OK as long as users connect directly to the web server.
However, when conecting thru an ISA server, sometimes one user sees
information belonging to another recent user.
The web server is configured for immediate page expiration.
Any ideas?
TIA Tag: authenticating to domain Tag: 515984
VS 2005 can not publish
An error occurred loading a configuration file: Failed to start monitoring
changes to 'F:\VBNETTEST\WebAimsSystem\AIMSSystem\bin' because the network
BIOS command limit has been reached. For more information on this error,
please refer to Microsoft knowledge base article 810886. Hosting on a UNC
share is not supported for the Windows XP Platform.
The KB article refers to keys in the registry that I don't have. I have XP
SP3.
What can I do?
--
Arne Garvander
Certified Geek
Professional Data Dude Tag: authenticating to domain Tag: 515982
Test post: Paypal
Just a test post to see if the mere act of mentioning paypal gets my message
excluded from this forum.
I ave tried twice today to ask question regarding cross-site posting to
paypal but the message never shows up :(
--
Rory Tag: authenticating to domain Tag: 515979
How to make a multi-line textbox to fill gridview's column in edit view?
Hi,
I have a multi-line textbox in a gridview when in edit mode. The textbox
(rendered as textarea in browser) set cols to 20 by default. I'd like the
textbox to 'adjust' itself to the width of the column. There are cases when
the column is much wider than the textbox. I could programmatically set
cols (through Columns property) but this is not going to work.
Is there a way to do that?
Thanks,
Dan Tag: authenticating to domain Tag: 515974
Database issue
I'm trying to build a hit counter that does what I want using an Access
database named counters.mdb which contains 2 tables. The only one involved
here is page_count. Here is the code for the aspx test page.
===============================
<%@ Page Language="VB" Debug="true" runat="server"%>
<%@ import Namespace="System.Data.OLEDB" %>
<script runat="server" language="vb">
Function pCount()
Const adOpenKeyset = 1
Const adLockPessimistic = 2
Const adCmdText = &H0001
Dim hCount As Integer
Dim sPage = Request.FilePath.Remove(0,Request.FilePath.LastIndexOf("/")
+1)
Dim sCmd = "SELECT * FROM page_count WHERE pagename='" & sPage & "';"
Dim dSource As String = Server.MapPath("counters.mdb"), sTest As String =
""
Dim rsCounter = Server.CreateObject("ADODB.Recordset")
rsCounter.Open(sCmd, "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
dSource & ";", _
adOpenKeyset, adLockPessimistic, adCmdText)
If rsCounter.EOF Then
sTest = "EOF has been reached."
'rsCounter.AddNew() 'uncommenting this line will throw an error
'rsCounter.Fields("pagename").Value = sPage
End If
rsCounter.Close()
rsCounter = nothing
Dim rTxt = "<p>The database path is: " & dSource & "</p><p>" & sTest &
"</p><p>The page is: " & sPage & "</p>"
Return rTxt
End Function
</script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Hit Counter Test</title>
</head>
<body>
<%Response.write(pCount())%>
</body>
</html>
=========================================
This produces the correct output, however if I uncomment the line
rsCounter.AddNew()
it starts throwing the following error
System.Runtime.InteropServices.COMException: Cannot update. Database or
object is read-only.
Could someone please tell me what is wrong? I've been at this since
yesterday.
PS: There will be line wrap issues in the above code and I have only
included that part of the If statement to the point of failure, the
rsCounter.update() etc. still has to be added in.
Thanks
BD Tag: authenticating to domain Tag: 515972
Try/Catch for Events
I am trying to capture event exceptions using try/catch.
I can get all exceptions with:
protected void dv_PR_ItemInserted(object sender,
DetailsViewInsertedEventArgs e)
{
if (e.Exception != null)
{
lbl_Errors.Text = e.Exception.Message.ToString();
e.ExceptionHandled = true;
}
else
{
Response.Redirect("~/PR/PR_Item.aspx?PR=" + tb_tPR.Text);
}
}
but then have to parse and switch() to get a meaningful message to the user.
Is there a way to use a try/catch in this situation so I can handle the
different exceptions individually? Tag: authenticating to domain Tag: 515969
FormView with DropDownList
Hi,
I have a database with Entries with many Categories (one to many).
Entries are shown by FormView. How can i show a DropDownList with
Categories to choose for every Entry?
Thanks in advance,
Etam. Tag: authenticating to domain Tag: 515964
DropDownList events not firing
Hi there,
I have a web form with some DropDownList controls that I am
trying to trap the selection change and run the attached server code.
However, even thought the controls have the runat property set to server,
the event code does not get executed. Anyone have any ideas? Tag: authenticating to domain Tag: 515961
Newbie VB ADO.Net Code to retrieve data from SQL table
I have created a table on SQL Server at GoDaddy with the following 3 fields:
ConstantID (e.g. WELCOME_MESSAGE)
LanguageID (e.g. EN-US)
LanguageText (e.g. "Hi and welcome to my new website")
The goal is that to make the website multi-lingual from the outset. Instead
of having "Hi and welcome to my new website" on the homepage, I'll use:
Response.Write(fGetText("WELCOME_MESSAGE"))
I have these questions:
1) For anyone who is familiar with SQL Server, what field types should I
use? Can I also have an incremental Autonumber field like MSAccess?
2) What would the ADO.Net code be to pull the LanguageText field data based
on ConstantID or MyAutoNumber? (I am a newbie)
3) In order for a Chinese friend of mine to populate the table after I have
finished it, how can I use a Datagrid read/write control on a webpage for
them to enter data (like Excel)?
TIA
Mark Tag: authenticating to domain Tag: 515954
FileName
Hi
I m facing a strange issue with filename
I am attaching an attachment (may be a notepad file, video file or whatever)
through a dummy customer page (customer.html) using a text box on this page.
I am getting the problem that my code is taking the entire path as file name
instead of that only name of attachment file name e.g. it should take only
attachment file name.
Dim file_coll As HttpFileCollection
Dim en_file_coll As IEnumerator
Dim postedfile As HttpPostedFile
file_coll = Request.Files
en_file_coll = file_coll.GetEnumerator
Do While en_file_coll.MoveNext
postedfile = file_coll.Item(i)
If postedfile.FileName.Length > 64 Then
Throw New local_exception("Filename too long " & postedfile.FileName)
Exit Do
End If
This postedfile.FileName is coming as â??C:\Documents and
Settings\wfmadmin\Desktop\testAttachmentFiles\att3.txt" instead of att3.txt
Is there any way to handle it? The file can be of any type (means *.text
file or *.pdf file or whatever and also it can be attached from any folder,
any location etc.)
Kindly help me
Thanks,
Deepak
+919886735837
kr_deepak123@hotmail.com Tag: authenticating to domain Tag: 515948
Uploading a directory instead of a file
I'd like to allow a user to point out a directory. There's facility for
pointing to a file, FileUpload, but there's nothing to get the path to a
given folder. How can that be solved (Silverlight is not an option).
Konrad Viltersten Tag: authenticating to domain Tag: 515946
Problem with retrieving cookie in ASP.net
I have a login form with =93Remember me on this computer=94 checkbox. I am
creating cookie if checkbox is checked. My code is:
If chk_remember.Checked =3D True Then
Dim ckUserName As HttpCookie =3D New
HttpCookie("CTUserName")
ckUserName.Value =3D Trim(txt_unm.Text)
ckUserName.Expires =3D
System.DateTime.Now.AddYears(4)
Response.Cookies.Add(ckUserName)
ckUserName =3D Nothing
End If
Now I am retrieving cookie on page load. It always gives me blank text
box of username. I don=92t understand why it gives null. Is that I am
doing anything wrong?
My code for retrieving cookie is:
If Not (Request.Cookies("CTUserName") Is Nothing) Then
txt_unm.Text =3D Request.Cookies("CTUserName").Value
End If
Any help will be appreciated.
Thanks,
SV Tag: authenticating to domain Tag: 515943
How can I retrieve the domain the web user is coming from? I want to only
give people from a certain domain access to a .aspx page.