Showing posts with label learning. Show all posts
Showing posts with label learning. Show all posts

Monday, March 26, 2012

Newbie cant get CSS working

Hi,

I'm learning to apply CSS on web site. I've put a link ref of the style sheets in the MasterPage.master. (Of course, the css files have been placed at the correct folder).

Inside VS2005, the look is ok; the CSS style applies correctly. But when I preview (or even after publish web site), the styles don't look like working. The colors simply the applied to the text.

I thought inheritance thru the MasterPage.master gave the problem. Then, I just create another webform page without inheriting master page. Putting the css links and the preview result still not ok. Though with VS2005 everything looks alright.

What i've missed? Thanks!

Jack LING

Head section of the MasterPage.master page:

<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=big5" />
<title>Live</title>
<link href="http://links.10026.com/?link=App_LocalResources/templates/template_css.css" rel="stylesheet" type="text/css" />
<link href="http://links.10026.com/?link=App_LocalResources/templates/theme.css" rel="stylesheet" type="text/css" />
</head>

Hi Jack,

Just a guess here, but I don't think the style sheet should be in the App_LocalResources folder - that strikes me as a special folder that may have varying contents depending where you publish the website. I could be wrong...

Could you run a little experiment? Try puting the stylesheets in the root of your web project and link to them appropriately:

<link href="http://links.10026.com/?link=template_css.css" rel="stylesheet" type="text/css" />

<link href="http://links.10026.com/?link=theme.css" rel="stylesheet" type="text/css" />

See if that corrects the problem. If so then consider moving the /templates folder out of the App_LocalResources folder and just have it sitting directly off the root.

Hope this helps!


Hi Draggor,


Great! Your reminder is correct! So, I won't put things to App_... folders until I learn more about its correct usage.

Thanks much!

Jack LING


is ther any reason you are placing the css file in side the APP_LocalResources folder? I don't think that folder accepts .css type of files and any access to that folder is denied i think.

You have to place the .css file somewhere else.

Saturday, March 24, 2012

Newbie Help! - Inserting Data into SQL

Hi All,

I need some help with ASP.NET 2.0. I come from a strong classic-ASP / VBScript / SQL development background and I'm now learning .net 2.0 to get back into the swing of things. So far I have hit a few snags, and this is the latest that I have not been able to get around.

What I have is 2 pages:

1. page1.aspx showing a single database record, with one of the rows in the detailsview a HyperLink row. This links to page2.aspx, with a Querystring of "id=", the value being the ID column of the displayed record. The single record that is shown is from a table called "tblBooks"

2. page2.aspx which I want to use to add a new record of data in a linked (but unrelated) table (tblAuthors - there can be any number of authors, hence another related table) to the one shown on page1.aspx.

What I want to do is get the querystring (Page.Request.QueryString("ID").toString) and feed it into the "BookID" field of the insert form on page2.aspx.

Firstly, is there an easier way that I am overlooking? If not, how do I get the BookID to be shown on page2.aspx, with the other 2 fields (Author first and last name) in insert mode?

Thanks in advance!!

Dominik.

Hello Dominik,

My suggestion is to use a business object to store and present your data. See the first 2 introduction tutorials onhttp://asp.net/learn/data-access/

After that you will have the feeling you stepped out of a time-machine and are light-years away from classic-ASP.

Jeroen Molenaar.


jeroenm:

My suggestion is to use a business object to store and present your data. See the first 2 introduction tutorials onhttp://asp.net/learn/data-access/

Wow, I wrote code behind a button, in the same way I would if designing a classic VB6-style application. That was after I created the dataset and associated Update, Insert, etc, functions in the designer. Very nice :-)

Thanks!

Dominik

Friday, March 16, 2012

NEWBIE NEEDS HELP! Listings dont run...

Hi,

I'm a newbie trying to get ahead of this learning curve but I'm having a lot of trouble getting listings and samples to run on my machine (Win XP, new box, IIS 5.1 installed, SMTP service started...). I'm using two books primarily, ASP .NET Unleashed 2nd ed. and Intro to ASP .Net by Kathleen Kalata (Thompson). I'm using VS .NET 1.1 and I'm having trouble with the samples and listings from both books. I think it may be an issue with IIS but I am so new to this I don't know where to begin and honestly I'd much rather be learning ASP than troubleshooting VS or IIS or whatever. Maybe that's naive but I'm pretty much in the dark either way. I'm hoping someone here will be able to help. I really want to learn this and its getting pretty frustrating. How am I supposed to find my mistakes if I can't even get the code provided with the books to work? Any way, here is is the code from ASP Unleased that is failing followed by the debug report. If this works out then maybe we can also look at the code from Kalata's book. I would be very grateful for a hand getting started with this.

//CODE SAMPLE Listing 1.12 pg. 45 of ASP .NET Unleashed

<%@dotnet.itags.org. Page Language="VB" Debug="true" %
<%@dotnet.itags.org. Import Namespace="System.Web.Mail" %
<Script Runat="Server"
Sub Page_Load
Dim mailMessage As SmtpMail

mailMessage.Send( _
"bob@dotnet.itags.org.somewhere.com", _
"alice@dotnet.itags.org.somewhere.com", _
"Sending Mail!", _
"Hello!" )
End Sub

</Script
<html>
<head><title>ImportNamespace.aspx</title></head>
<body
<h2>Email Sent!</h2
</body>
</html>
//END CODE SAMPLE

//ERROR REPORT
Server Error in '/' Application.
------------------------

The "SendUsing" configuration value is invalid.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: The "SendUsing" configuration value is invalid.

Source Error:

Line 8: Dim mailMessage As SmtpMail
Line 9:
Line 10: mailMessage.Send( _
Line 11: "bob@dotnet.itags.org.somewhere.com", _
Line 12: "alice@dotnet.itags.org.somewhere.com", _

Source File: c:\inetpub\wwwroot\asp-unleashed\MyFiles\chap01\ImportNamespace.aspx Line: 10

Stack Trace:

[COMException (0x80040220): The "SendUsing" configuration value is invalid.
]

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters) +0
System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters) +473
System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) +58

[HttpException (0x80004005): Could not access 'CDO.Message' object.]
System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) +113
System.Web.Mail.CdoSysHelper.Send(MailMessage message) +1840
System.Web.Mail.CdoSysHelper.Send(String from, String to, String subject, String messageText) +74
System.Web.Mail.SmtpMail.Send(String from, String to, String subject, String messageText) +171
ASP.ImportNamespace_aspx.Page_Load() in c:\inetpub\wwwroot\asp-unleashed\MyFiles\chap01\ImportNamespace.aspx:10
System.Web.Util.ArglessEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +10
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731

------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573
//END ERROR REPORTIt apparently can't find an SMTP server, with which to send the email

First - is it WinXP Home or WinXp Pro - -
You'd need WinXP pro to have IIS and an smtp running on your computer - - and:
Secondly - do you have an SMTP server running on your computer?
Thanks David,

(XP Pro) Well, that's what I though also. So I checked control panel/ services and found that SMTP is running. I'm running IIS locally as a student and I doubt somehow that I could actually send email from this server to a mail recipient on the web through my Verizon DSL account but that shouldn't stop the page from running, right? Maybe this is some configuration issue?
There are all kinds of issues with sending e-mails and .net

we are fighting with the CDO stuff right now as well - the issue
is with CDONTS

there are MANY FAQ's and tech white papers on how to fix this problem -
but so far NONE have corrected it...

here is a link to a joint that is having the exact same problem...

http://www.ultraapps.com/disc_thread.asp?mid=2712&app_id=1&

and this link...

http://www.genesis-hosting.com/?pagename=cdontshowto

we did all the suggested stuff, and it still doesn't work ...

good luck
No. Seriously? Using forms to send email is like the most basic thing going. How could something as sophisticated and successful as ASP .Net fail on something so basic. I find this very hard to beleive and that newsgroup you sent me too isn't quit right either, is that some kind of demo for the applications for sale on the site or are you for real?

I just want someone to look at the code and error report and tell me what they tink is going on. 57 people have read this and only 3 have responded. Does this mean that none of you know what is going on or what?
Try modifying the following code snippet:

Dim lMailMsg As New Mail.MailMessage
lMailMsg.To = "bob@.somewhere.com,alice@.somewhere.com"
lMailMsg.From = "ubwa@.somewhere.com"
lMailMsg.Subject = ""Sending Mail!""
lMailMsg.Priority = Mail.MailPriority.High
lMailMsg.BodyFormat = Mail.MailFormat.Text
lMailMsg.BodyFormat = rbutBodyFormat.SelectedItem.Value
lMailMsg.Body = "Hello!"

' Commented out example of how to handle attachments
'Dim lAttachment As New Mail.MailAttachment("c:\temp\TestAttachment.txt", Mail.MailEncoding.Base64)
'lMailMsg.Attachments.Add(lAttachment)

Dim lSMTPMail As Mail.SmtpMail
lSMTPMail.SmtpServer = ConfigurationSettings.AppSettings("SMTPServer") ' This should be the IP address of your Verizon SMTP server
lSMTPMail.Send(lMailMsg)

You are correct that sending email is a very basic concept. The issues that I have had all revolove around correctly configuring the SMTP server component on the backend.
I ran the script you posted ubwa and everything worked fine. I could not reproduce your error.
I would also recommend that you use try/catch error handling in your code to determine what is really going on as well. You should also be aware that the outermost exception message is usually not meaningful when working with SMTP mail. Refer to the following code snippet:

dim lLogText as string

try

...your email code

catch ex as exception

If IsNothing(ex.InnerException) = True Then
lLogText = "Failure encountered while attempting to email a report:" & vbCrLf & vbCrLf & ex.Message & vbCrLf & vbCrLf & ex.StackTrace
ElseIf IsNothing(ex.InnerException.InnerException) = True Then
lLogText = "Failure encountered while attempting to email a report:" & vbCrLf & vbCrLf & ex.InnerException.Message & vbCrLf & vbCrLf & ex.StackTrace
Else
lLogText = "Failure encountered while attempting to email a report:" & vbCrLf & vbCrLf & ex.InnerException.Message & "::" & ex.InnerException.InnerException.Message & vbCrLf & vbCrLf & ex.StackTrace
End If

.... write to an external log file

end try
Yes - I am for real - and as you have seen from the
trouble you are having - there is a problem.

If you were to take a few moments and read the posts for both of those sites,
you would have seen that you are not alone in this problem.

As for you getting cocky and bashing us for trying to help you,

you posted the request for free help

FREE help -

we don't work for you - we are volunteering our time to try to assist you in your efforts.

If you don't like the answers or suggestions that are given - then don't post questions here.

Pretty simple concept.
Whoa, please, I meant no offense and it wasn't my intention to bash anyone. I very much appreciate this community and the time people take help others. If my tone is off its just because I'm frustrated that I'm spending more time troubleshooting than I am learning to use ASP .Net. I apologise.