Yes you can do it. If your Class Library project is referenced by your ASP.NET application, you can use below code in your Class Library project to get the connection string from Web.Config File.
System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionStringKeyName"]
This is assuming you are storing your connection string inside
<connectionStrings>
node in your Web.Config file.
Hope that helps!