asp.net-3.5

Getting Error Msg - Cannot implicitly convert type 'string' to 'bool'

淺唱寂寞╮ 提交于 2019-11-28 06:39:38
问题 I am checking for values in a textbox to trigger a conditional statement, but am getting error messages. if (txtAge.Text = "49") || (txtAge.Text = "59") { txtNote.Text = "A valid picture ID must be submitted"; } The error message I am getting is Cannot implicitly convert type 'string' to 'bool' How can I resolve this? 回答1: When you type this: if (txtAge.Text = "49") This basically is assigning "49" to txtAge.Text , and then returning that value as a string (equal to "49"). This is the same,

Making user login persistant with ASP .Net Membership

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-28 06:27:09
I have a website that is built in ASP.NET 3.5 & SQL Server 2005, using the sql membership provider, and presumably forms authentication. Since security needs on my site are very low, I would like to authenticate once, and then keep the log in persisted indefinitely (without giving the user the choice). What is happening is that the user logs in, stays logged in for the session, and then the next time they arrive, they are logged out. How can I get the log-in persisted? Here's the technical details, I have experimented with many variations of durations. Try If Membership.ValidateUser(UserName

How to sort ResourceSet in C#

笑着哭i 提交于 2019-11-28 05:55:00
问题 I have a resource file named filetypes.resx. Some how I figured out to bind the resource values to dropdownlist, but I don't know how to sort the values of ResourceSet . Here is what I did so far, FileTypes.resx Name,Value A,1 B,2 C,3 code to bind dropdownlist DropDownList1.DataSource = Resources.FileTypes.ResourceManager.GetResourceSet(System.Globalization.CultureInfo.CurrentCulture, true, true); DropDownList1.DataTextField = "Key"; DropDownList1.DataValueField = "Value"; DropDownList1

creating a user in Active Directory: A device attached to the system is not functioning

元气小坏坏 提交于 2019-11-28 04:31:07
Consider this code attempting to create an Active Directory account. It's generating an exception here with a certain set of data. It's not clear right now what's causing the exception. var user = new UserPrincipal(someValidUserContext, ".x-xyz-t-FooFooBarTest", "somePwd", true); user.UserPrincipalName = ".x-xyz-t-FooFooBarTest@foobarbatbaz.net"; user.SamAccountName = ".x-xyz-t-FooFooBarTest"; user.DisplayName = "Some String 16 chars long"; user.Name = "Some String 16 chars long"; user.Description = "Foo BarBaz 12 more characters"; user.AccountExpirationDate = someDateInFuture; user

How to make update panel in ASP.NET MVC

ぐ巨炮叔叔 提交于 2019-11-28 02:47:05
How do I make an update panel in the ASP.NET Model-View-Contoller (MVC) framework? You could use a partial view in ASP.NET MVC to get similar behavior. The partial view can still build the HTML on the server, and you just need to plug the HTML into the proper location (in fact, the MVC Ajax helpers can set this up for you if you are willing to include the MSFT Ajax libraries). In the main view you could use the Ajax.Begin form to setup the asynch request. <% using (Ajax.BeginForm("Index", "Movie", new AjaxOptions { OnFailure="searchFailed", HttpMethod="GET", UpdateTargetId="movieTable", })) {

ASP.NET Markup Intellisense not working in Visual Studio 2010

不想你离开。 提交于 2019-11-28 01:12:08
问题 When I type < in the Markup Mode of Visual Studio 2010, I don't get any server-side controls (ie. <asp:textbox /> ), I just get a list of standard HTML controls. This used to work, but one day just stopped. Why could this be? P.S: I'm a VB.NET Programmer, and intellisense is working fine in the .vb files. 回答1: Navigate here: C:\Users\USERNAME\AppData\Roaming\Microsoft\VisualStudio And delete the contents of the folder labeled '10.0'. This worked for me. 回答2: Check file extension - editor

Sharing session state between 2 ASP.NET applications using SQL Server

允我心安 提交于 2019-11-28 00:03:46
I'm working on a site that has a requirement to share session between a cms application and an online store application on the same domain eg. mydomain.com and store.mydomain.com I've made some progress with it and it works on my local build between localhost/cms and localhost/store Basically I have done what is suggested in this article http://blogs.msdn.com/toddca/archive/2007/01/25/sharing-asp-net-session-state-across-applications.aspx and hacked the TempGetAppID Stored Procedure to return the same application id (1). This appears to work as it creates sessions with ids like

Get item count of a list<> using Linq

纵然是瞬间 提交于 2019-11-27 23:16:05
问题 I want to query a List<> and find out how MANY items match the selection criteria. using LINQ and c# /.net 3.5. How would I modify the query to return an int count. var specialBook = from n in StoreDisplayTypeList where n.DisplayType=="Special Book" select n; 回答1: var numSpecialBooks = StoreDisplayTypeList.Count(n => n.DisplayType == "Special Book"); This uses an overload of Enumerable.Count that takes a Func<TSource, bool> predicate to filter the sequence. 回答2: Try this: int specialBookCount

What Causes “Internal connection fatal errors”

二次信任 提交于 2019-11-27 21:20:20
I've got a number of ASP.Net websites (.Net v3.5) running on a server with a SQL 2000 database backend. For several months, I've been receiving seemingly random InvalidOperationExceptions with the message "Internal connection fatal error". Sometimes there's a few days in between, while other times there are multiple errors per day. The exception is not limited to one site in particular, though they share business and data access assemblies. The error seems to always be thrown from SqlClient.TdsParser.Run(). It sometimes is thrown from old-school direct SqlCommand.Execute() calls, while other

Check that email address is valid for System.Net.Mail.MailAddress

不想你离开。 提交于 2019-11-27 17:10:23
问题 Currently, to avoid errors from being thrown up due to invalid email addresses, I do the following: Dim mailAddress As MailAddress Try mailAddress = New MailAddress("testing@invalid@email.com") Catch ex As Exception 'Invalid email End Try However, rather than depending on Try..Catch , is there a way of validating that the email address will be 100% valid for the MailAddress type? I know there a plenty of regex functions out there for validating emails, but I'm looking for the function which