Problem with .net elements in vb.net Response.Write

I need to do a response.write on an aspx page in vb.net , where as the response.write will display on "if" condition. I'm trying to display an Iframe that contains another file, with querystring parameters. Even when I double up/escape the quotation marks, still get a "String constants must end with a double quote" error on this line:

 

<%= response.write("<IFRAME src=banners/nv-A1List.aspx?zone=<%=request.querystring(""zone"")%> name=banner width=234 height=60 frameborder=no border=0 MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING=no></IFRAME>")  %>

 

??? 

chumley 

0
Chumley
12/21/2007 9:10:29 PM
asp.net.getting-started 91979 articles. 4 followers. Follow

7 Replies
2083 Views

Similar Articles

[PageSpeed] 6
Get it on Google Play
Get it on Apple App Store

Resposne.Write will inject the output at the top of the apsx when it is rendered, which is actually before the opening <html> tag.  That's not what you want, and is the main reason that Response.Write isn't used in ASP.NET.  What you should do is use a Literal Control, and set its Text property in your If statement:

Literal.Text="<IFRAME src=banners/nv-A1List.aspx?zone=" & request.querystring("zone") & " name='banner' width='234' height='60' frameborder='no' border='0' MARGINWIDTH='0' MARGINHEIGHT='0' SCROLLING='no'></IFRAME>"

 


Regards Mike
[MVP - ASP/ASP.NET]
My site
0
Mikesdotnetting
12/21/2007 9:20:03 PM

 Thanks for offering, the problem is, i need to display this outside of  a function, subroutine, form, etc. ; Literal.Text needs some sort of reference of a member....response.write works on simpler aspx, just need to find a way to escape the "escapables" properly.

chumley 

0
Chumley
12/21/2007 9:57:56 PM

On an aspx page try the following: 

        <iframe frameborder="no" height="60" marginheight="0" marginwidth="0"
            name="banner" scrolling="no" src='default.aspx?zone=<%=request.querystring("zone")%>'
            style="position: static" width="234"></iframe>

 Notice I've used single quotes for the src='default.aspx?zone=<%=request.querystring("zone")%>' This is because you must use single outside if an element inside needs double. And I havent used <%response.write() either. Just place this in the aspx source where you want the IFrame. If you are going to use code behind and set the literal1.text then ithe useage of quotes seems to be the other way round like this: 

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Literal1.Text = "<iframe frameborder='no' height='60' marginheight='0' marginwidth='0' name='banner' scrolling='no' src='default.aspx?zone=<%=request.querystring('zone')%>' style='position: static' width='234'></iframe>"
    End Sub 
 

Notice I've used default.aspx in both cases as your URL is not known on my pc.


Regards
Smcoxon

No Gem is ever polished without some friction.
0
smcoxon
12/21/2007 10:10:42 PM

Chumley Walrus:

Literal.Text needs some sort of reference of a member....

 

Yes.  You put a Literal control on the page.  It renders as nothing unless you apply its Text property.

 


Regards Mike
[MVP - ASP/ASP.NET]
My site
0
Mikesdotnetting
12/21/2007 10:30:45 PM

when trying this, i get an "Object variable or With block variable not set" exception, pointing to the line in my function at literal1.text  :

<script runat="server"> 

Protected Function showiframe() as String
       
Literal1.Text = "<iframe frameborder='no' height='60' marginheight='0' marginwidth='0' name='banner' scrolling='no' src='default.aspx?zone=<%=request.querystring('zone')%>' style='position: static' width='234'></iframe>"

  End Function

</script>

 ''in aspx page:

 <%=showiframe() %>

 

0
Chumley
12/26/2007 8:35:33 PM

So what you are saying is that you want to mix ASP with ASP.NET correct?  It isn't possible to do - the aspx page cannot interpret vbscript.

This link shows how to work with iframes in .NET:

http://www.eggheadcafe.com/tutorials/aspnet/4c4c5f62-678e-4e05-87fd-4477a0d1987c/using-serverside-iframes.aspx

0
kraznodar
12/26/2007 9:32:39 PM

Hi, as you are using VB code embedded in the aspx page, instead of using a VB code behind file, and you're using a Function that is called by <%=showiframe() %> on the aspx page, you dont need a Literal control on the page. However, you do need to return the iFrame setup string to the call by setting the Function Return value. Below is the page aspx script with embedded VB code. I'd recomend you use code behind pages and revert back to setting a Literal controls text property though!

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

    Protected Function showiframe() As String
        Return "<iframe frameborder='no' height='60' marginheight='0' marginwidth='0' name='banner' scrolling='no' src='default.aspx?zone=<%=request.querystring('zone')%>' style='position: static' width='234'></iframe>"
    End Function

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <%=showiframe() %>
        </div>
    </form>
</body>
</html>
   
Regards
Smcoxon

No Gem is ever polished without some friction.
0
smcoxon
12/26/2007 11:12:17 PM
Reply:

Similar Artilces:

Sending SMS using vb.net or C#.net using vb.net or c#.net
Hi  My requirement is I hav one csv file with these fields id,mobilenum,messgae,status.intiallu staus is 0. once i read the all fileds and take that mobile number.using tat mobile number  i need to send sms .after sending sms i shuld change status as 1 How to send sms thru coding (please dont provide any links.if it is provide also please give working links becox i checked codeproject .i didnt get any nice link. and also provide the how to update the status field im csv file   Thank ssandhya   To send SMS, you need some third party SMS providers. if you consul...

converting to vb.net from c#.net authorize.net
authorize.net offered me some sample code when I signed up with them the only problem is the sample code is in c#.net but my page that they type all of their credit card into is vb.net <code><%@ Import Namespace="System.Net" %> <%@ Import Namespace="System.IO" %> <script language="C#" runat="server"> void Page_Load(Object Src, EventArgs E) { myPage.Text = readHtmlPage("https://certification.authorize.net/gateway/transact.dll"); } private String readHtmlPage(string url) { ...

Problems while porting .Net framework 1.0 (VB.Net) application to .Net Framework 1.1
Hello,   I have a ASP.Net web application,written in VB.Net,developed on .Net Framework 1.0 .I am trying to port it on to .Net framework 1.1.   For achieving this,I follow the following steps-   1.Open the project using the .vbproj file. 2.I am prompted with the conversion message "Do you want to convert the solution and all projects to .Net framework  1.1....." 3.I click "Yes" 4.I assume that the project is now converted. 5.I build the project & try to run it. 6.I get the following error -     Server Error in '/Consert.Net' Application. ...

Net:Net:Net::LDAP::FAQ
------_=_NextPart_001_01C6429F.D89AA417 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hello, Net::LDAP Net::LDAPS Is there a possible to LDAP bind with an encrypted (SHA, SSHA, CRYPT, ....) password? I don't like to write the secret password to the perl file. Best regards Barbara Wilbert ------_=_NextPart_001_01C6429F.D89AA417-- Wilbert Barbara (CI/OSI) * wrote: > Hello, > > Net::LDAP > Net::LDAPS > > Is there a possible to LDAP bind with an encrypted (SHA, SSHA, CRYPT, > ......

vb.net vs c#.net vs j#.net
just out of curiousity which looks, acts most like java? i'm still learning trying to used to vb.net but it seems that it was easier to do some stuff with java. C# is Java++ in my opinion. If you have done C or Jave you will prefer C#.Mike Schellenberger - MCAD If you are looking for language similar to java go for J#. However most code samples you find on the net will be in VB.NET and C#....

Problem VB.NET 2003 and DataWindows.net
Greetings: When trying to add manually DataWindows.net 2.0 control to my Vb.Net 2003 studio I get the following message: DataWindowInterop.dll is not a Microsoft.Net module I get the same error when trying to add DataWindow.dll Can someone advise how to resolve this problem? Thanks Hello, I am having the exact same problem. Is it even possible to use Datawindow 2.0 in Vb.Net 2003? If so what's the trick? DW .NET installed fine but the controls on the tool box don't show up. I tried adding DLL's both ways as a .NET and a COM component but neither worked. Any ...

How to get RS (From VB6) to .NET (VB.NET)
Hi Friends,         I have requirement, there is one function in VB6 it returns a RS, I need to call that function in  VB.NET, how to get those values into .NET, if can any body can help (pass me some code snippets), that will be greate, Thank you.Madhu... -Madhu hey guys i got this one just by using fill method.-Madhu...

upgrading vb.net to vb.net 2003 crystal report viewer problem.
I have a vb.net web. app that has several pages each with a different crystal report on it. It works perfectly under vb.net. I've since installed vb.net 2003. After I open the solution in 2003 & it does its upgrade, all of the crystal report viewer controls are corrupted. If I try to run it as is I get the following error: "The base class includes the field 'myname' but its type (CrystalDecisions.Web.CrystalReportViewer) is not compatible with the type of control(CrystalDecisions.Web.CrystalReportViewer). So I tried deleting the control and adding back on. & when I ru...

how can i write this line using vb.net : container.dataitem ?.... in vb.net its not working
Dim container As GridView = CType(newLinkButton.NamingContainer, GridView) Dim dataValue As Object = DataBinder.Eval(container.dataitem, _ColName)   _ColName its just a string a name of the field in my database   This is Vb.Net code man what you want? You can convert any format from this link http://www.developerfusion.com/tools/convert/vb-to-csharp/  If this post is answer of your question then don't forgot to Click Mark As Answer...

use VB.NET and C#.NET code in the same C#.NET project
All-- Here is a sample that is "off the beaten path", (at least for me). Is it possible, in an ASP.NET application, using the code-behind page building technique, to have both pages written in VB.NET and pages written C#.NET?At http://www.WebLogicArts.com/DemoList.aspx there is a sample that shows that, (contrary to popular belief), it IS possible to mix ASP.NET pages built with C#.NET with ASP.NET pages built with VB.NET in the same VS.NET 2003 project. Note that this is just a "fun" sample to see if it can be done and I do not recommend this practice as a "standard" way of develo...

vb .net or c# .net
I currently develop websites using php but have been requested to develop a site using asp.net. The question I have is for someone who knows php would it be better to transition to vb.net or c#.net? Thanks, Fr. Robert C# -> There is a converter that will transition about 60% or more of your PHP code to C#. Plus C# is closer to PHP than VB.NET.Jason N. GaylordASPInsider and Microsoft MVPhttp://jasongaylord.com...

VB.Net To C#.Net
Hello... Since Last from 1 year i had develope web application in using vb.net now i want to transfer from vb.net to c#.net so what should i do to transform to c# language any link or book related to me through i can easily understand and coding using c# in a short time... Thanks~ Mark As Answer If UseFull ~Kaushal. Hi, you can read the specifications of the language. You're already familiar with .NET and how to program in an OO manner thanks to your experience with vb.net. The only thing you need to learn is the new syntax of C#. You can also convert parts of your v...

About VB.net And VC.net
I am always Programming With VB.net Recently My Teacher ask us to learn Vc or VC.net. I try to learn it and compare it with vb.net, I found it's much too complex than vb. However it is said vc is strongger than vb I want to know Why vc is strongger than vb? and is it hard too learn vc? I am new to asp.net Thanks for man who want to help me! Wuhan, Hubei, China Below links could give some info http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q308470Sreedharhttp://www.w3coder.orgweblog http://weblogs.asp.net/skoganti VisualC is not a language in an of itself...

C#.NET or VB.NET
what lang does everyone prefer? Thanks, Peter Iuvara, MCP It's a very famous debatable question in forums! I would say if you are from Java/C/C++, then C# would be easy to use for you. If you are from ASP/VB, then VB.NET would be easy for you! As long as if you follow CLS, then what ever the language you use, it's going to be the same for CLR!Sreedharhttp://www.w3coder.orgweblog http://weblogs.asp.net/skoganti I would agree with that ... just curious as to what user's on this forum predominantly code in?Thanks, Peter Iuvara, MCP I came from no real programming background, started i...