Thursday, March 29, 2012
Newbie: how to handle large response.write blocks
Is there a way to abbreviate the aspx below? Specifically, is there a
way to eliminate the response.write syntax and escaped characters?
<%
if (MyObject.SomeBoolean)
{
Response.Write("<div class=\"myclass\">");
Response.Write("You may have won 1,000,000 dollars...");
Response.Write("lots of text...");
Response.Write("lots of text...");
Response.Write("</div>");
}
else
{
Response.Write("<div class=\"error\">");
Response.Write("You should buy more magazines...");
Response.Write("lots of text...");
Response.Write("lots of text...");
Response.Write("</div>");
}
%>
Thanks.
BrianIn C#, Not. If you want to have a literal quote in a string you have to plac
e
the \ escape before it.
Regarding not having to type Response.Write so much, try stuffing all your
strings into a StringBuilder instance. At the end, you can write one time:
Response.Write(myStringBuilder.ToString());
Peter
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
"Brian F" wrote:
> Hi everyone -
> Is there a way to abbreviate the aspx below? Specifically, is there a
> way to eliminate the response.write syntax and escaped characters?
> <%
> if (MyObject.SomeBoolean)
> {
> Response.Write("<div class=\"myclass\">");
> Response.Write("You may have won 1,000,000 dollars...");
> Response.Write("lots of text...");
> Response.Write("lots of text...");
> Response.Write("</div>");
> }
> else
> {
> Response.Write("<div class=\"error\">");
> Response.Write("You should buy more magazines...");
> Response.Write("lots of text...");
> Response.Write("lots of text...");
> Response.Write("</div>");
> }
> %>
> Thanks.
> Brian
>
Newbie: how to handle large response.write blocks
Is there a way to abbreviate the aspx below? Specifically, is there a
way to eliminate the response.write syntax and escaped characters?
<%
if (MyObject.SomeBoolean)
{
Response.Write("<div class=\"myclass\">");
Response.Write("You may have won 1,000,000 dollars...");
Response.Write("lots of text...");
Response.Write("lots of text...");
Response.Write("</div>");
}
else
{
Response.Write("<div class=\"error\">");
Response.Write("You should buy more magazines...");
Response.Write("lots of text...");
Response.Write("lots of text...");
Response.Write("</div>");
}
%
Thanks.
BrianIn C#, Not. If you want to have a literal quote in a string you have to place
the \ escape before it.
Regarding not having to type Response.Write so much, try stuffing all your
strings into a StringBuilder instance. At the end, you can write one time:
Response.Write(myStringBuilder.ToString());
Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
"Brian F" wrote:
> Hi everyone -
> Is there a way to abbreviate the aspx below? Specifically, is there a
> way to eliminate the response.write syntax and escaped characters?
> <%
> if (MyObject.SomeBoolean)
> {
> Response.Write("<div class=\"myclass\">");
> Response.Write("You may have won 1,000,000 dollars...");
> Response.Write("lots of text...");
> Response.Write("lots of text...");
> Response.Write("</div>");
> }
> else
> {
> Response.Write("<div class=\"error\">");
> Response.Write("You should buy more magazines...");
> Response.Write("lots of text...");
> Response.Write("lots of text...");
> Response.Write("</div>");
> }
> %>
> Thanks.
> Brian
>
Saturday, March 24, 2012
Newbie: Simple Help
Hello Everyone
I am new to ASP.NET. I need help on converting one line of code , which has been giving me a problem. I tried to add Response.Write () and remove <% %>, but it doesn't work. The line of code is in BOLD.
<script language=vbscript runat=server>
Sub MakeButton(ButtonName, OnClickFunc, IsSelected, UpImage, DownImage, HelpText)
Dim image
If IsSelected Then
image = DownImage
Else
image = UpImage
End If
%>
<IMG src="http://pics.10026.com/?src=<%=image%>" BORDER=0 NAME="<%=ButtonName%>" ONMOUSEDOWN="javascript:<%=OnClickFunc%>('<%=ButtonName%>');" ALT="<%=HelpText%>">
<%
End Sub
</script>
Thanks in advance
btran
ASP.NET doesn't work that way. The way you are doing it is seems to be based around the old ASP Inline style. Try the following:Sub MakeButton(ButtonName asString, OnClickFunc asString, IsSelected asString, UpImage asString, DownImage asString, HelpText asString)Dim imageIf IsSelectedThen image = DownImageElse image = UpImageEnd IfDim imageObject as HtmlImage = new HtmlImage()imageObject.Alt = HelpTextimageObject.Src = imageimageObject.Name = ButtonNameimageObject.Attributes.Add("onmousedown",String.Format("javascript:{0}('{1}');", OnClickFunc, IsSelected))Me.Controls.Add(imageObject)End SubHowever looking at this code may I suggest that you refactor it so that everything flows in a more object oriented way. This seems very linier in the way you are approaching ASP.NET.
Friday, March 16, 2012
News Letter
How to store email address?
What software we use for newsletter?
I dont know anything about news letter.Hey,
If you have Office, use Word to do a newsletter. Store the email address of who it goes to and the path to the newsletter in the database, then write a program or manually send out the newsletter based on the email addresses there. You probably don't have to store the path to the newsletter if you are doing only one a month.
Brian
I have my newsletter written in HTML.
I have all the email addresses stored in database.
I want to use asp.net to send the newsletter.
For sending to multiple email addresses, stored in a database:
http://aspnet101.com/aspnet101/tutorials.aspx?id=15 (actually two different tutorials on this - two different ways of doing it.
for reading an HTML based text file:
http://aspnet101.com/aspnet101/aspnet/codesample.aspx?code=wishes