Classic ASP Response write statement - asp-classic

In html these are working, how to I write a code which uses response write statement in classic asp for HTML statement below?
<div id="the_div" style="border: 1px solid red"><iframe src=asp3.asp> <br><br></div>
Hide the div until this link is click again.<br>
Remove the div until this link is click again.
I tried below but not succesful, huh?
response.write "<div id='the_div'><iframe src=asp3.asp> </iframe><br><br></div>"
response.Write ""Hide the div until this link is click again.<br>"
response.Write ""Remove the div until this link is click again."

Use double double quotes if you need to escape them within a Response.Write statement, ie
Response.Write "<div id=""the_div"" style=""border: 1px solid red""><iframe src=""asp3.asp""> </iframe><br><br></div>"
Response.Write "Hide the div until this link is click again.<br>"
Response.Write "Remove the div until this link is click again."
You can use single quotes instead of double quotes as you tried to do, but if you're already using them with JS onclick events it starts to look very confusing, and you might find there's a conflict

Related

ASP.NET Hyperlink control not render href on ascx webpart

I have a Hyperlink control on an .ascx that looks like this:
<asp:HyperLink ID="hDocument" NavigateUrl="http://www.google.com" Text="Delegate Approval" Target="_blank" runat="server"></asp:HyperLink>
However, when I navigate to my SharePoint page where this URL is supposed to be displayed, the hyperlink is not clickable and there is no href in the HTML anchor tag () like so:
<a id="ctl00_ctl40_g_65ace0cb_fdf4_4d40_ae31_9736b2d39022_gvLevel1Approvals_ctl02_hDocument" target="_blank">Delegate Approval</a>
I place a normal HTML anchor under the Hyperlink control and that one works fine. I have no idea why the Hyperlink control doesn't produce a href attribute when it renders.
Edit:
Here's the original code:
<asp:HyperLink ID="hDocument" runat="server"></asp:HyperLink>
code behind
HyperLink hDocument = (HyperLink)e.Row.FindControl("hDocument");
hDocument.Text = "Delegate Approval";
hDocument.NavigateUrl = // builiding URL here;
hDocument.Target = "_blank";
I had the same issue and could solve it only by setting the NavigateUrl in Code Behind (in Page_Load).
So our situation with the was it would work only intermittently but 95% of the time it didn't work. Everything else worked fine: building the URL in the code behind, setting the link text, everything. We could not figure out why the href would not show up on the page on the client browser. In the end I eventually switched to using a regular HTML anchor tag and added in the System.Web.UI.HtmlControls namespace to find the anchor and modify that in the code behind.
I found the solution.
In VB.net
HyperLink1.Attributes.Add("href", "http://www.clarin.com")
In my situation Visual Studio converted ASPX to HTML5.
When VS converts the document to HTML - if you perform some debugging - you will see:
<a NavigateURL="someurl" blablabla
but NavigateURL is not found in HTML.
You MUST replace the attribute NavigateURL with href.
I do not know if this is a compiler error, but it was the only reasonable solution I could find.

Displaying html page in ASPX page

I need to display dynamic created html in aspx(server side html);
I tried to use Iframe but it will not displaying anything ; it will not work because of security reasons ;
Is there is any controls that will display html page? Dynamic html have its on css and javascripts so I can’t use html text box controls.
If anyone have solution please help
Thanks
Since your dynamic page has its own CSS & Javascript, I'm assuming it's not written to coexist with its host page. I'm also assuming that when you tried to use the iFrame you just tried to write straight to it from the containing page.
I would suggest moving your code that generates the HTML to a separate ASPX page and referencing that page as the source of your iFrame or rewriting your CSS & Javascript so it will coexist and using a DIV.
Also, it's sort of hard to come up with a workable solution without you showing some of the code you have currently.
Have a look at the
<asp:Literal>
control. There's an example here: Set ASP Literal text with Javascript
-- EDITED 03/05/2012 --
Simple example of an asp.net literal control in action:
.aspx code
<asp:Literal ID="MyLiteral" runat="server" />
.vb code behind
Dim k As String
k = "<table style=""border: 1px solid red;""><tr><td>Cell 1</td></tr><tr><td>Cell 2</td></tr></table>"
MyLiteral.Text = k
If I compile this in VS2008 I get a two row table with a red border in IE.
I found the answer!! Use UFRAME!! It's simple and easy!! uframe.codeplex.com

Display large text from database on asp.net page with proper spacing and indent?

I was just wondering out of curiosity if it was possible to display large text from a database in a HTML or asp.net page with proper indenting and spacing?
As of right now, I have it displayed in a textbox and I'm using a highlight specific text feature incorporated in my site that doesn't function ONLY when the length of the text is greater then actual textbox. So I was thinking of displaying the data on a page and considering using Response.Write but the displayed text is all bunched together without proper indenting or spacing.
Ex.) instead of..."Hey Everyone how is everyone doing today? I am sample text"...is possible to display it as...
"Hey Everyone
How is everyone today? I am sample text"
Would anyone guide to any proper method that I could use or know of any info
New Line will be like \r\n in code behind text
Now, you can use Span or Literal control like below in HTML
HTML Side
<span id="span" runat="server"></span>
<asp:Literal id="literal" runat="server"></asp:Literal>
Code Behind side
span.InnerHtml = yourtext.Replace("\r\n","<br/>")
Without knowing anything about what format the text is stored in the DB (I'm assuming it's just regular spacing & carriage returns.
You could put it between <pre> tags. e.g.
ASPX
<pre>
<asp:Label ID="myTextArea" runat="server" />
</pre>
CODE BEHIND
myTextArea.Text = //Code to get text string from DB
If there are carraige returns already embedded in the text, you could do replace them with <p> tags, like:
string value = // get value from database ;
string formattedValue = string.Format("<p>{0}</p>", value.Replace("\r", "</p><p>"));

Asp.net dynamic controls from l2e

G'day, I have an aspx page that has its html stored in a sql server 2008 table which uses linq to entities to retrieve & display in a placeholder on the page. This all displays correctly except for an asp button that will not display. Viewing the source of the page shows that the button is there but it is not on the page.
Page = Page.Replace("!LOGINBUTTON!", "< asp:Button id='login' text='Login' runat='server' />")
How do I get it to display?
Thanks.
Whatever code you are replacing with !LOGINBUTTON! is .ASPX code. It is not a pure HTML to display button.
When ASP.net actually render page asp:Button Converted with HTML <Input Type="Button" ..... with appropriate Javascript functions(for postback).
In this case if you want to see button with its postback event you need to write
Page = Page.Replace("!LOGINBUTTON!", "< intput type='Button' id='login' text='Login'/>")
I hope it will work.

How to disable a link based on the database value (ASP page)

I would like to disable a link based on the database value (ASP page). Does anyone know how to do this? Are there any example available? Need your help. Thanks.
This is a pretty vague question but in Classic ASP you can use VBScript to test your database value and then Response.Write out either the anchor tag or just a span tag with the text:
<%
If CBool(rs("showlink")) = True Then
%>
Link Text
<%
Else
%>
<span>Link Text</span>
<%
End If
%>
This assumes that you are getting a recordset back from the database (named rs) and that it has a field on it called "showlink" that will indicate if the anchor tag should be displayed or not. Small side note: Keep in mind that showing or hiding the anchor tag is not a replacement for proper authentication/security.

Resources