This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Dreamweaver > August 2004 > ASP.NET C# writer.WriteAttributeString





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author ASP.NET C# writer.WriteAttributeString
Shaine Fisher

2004-08-07, 7:15 pm

Please help, it's prob really easy but I can't get this to work. I
want to put a database field result value into a WriteAttributeString,
but I keep getting the error:


Here is the code, I know where the problem is (marked with ***) but
not how to fix it!

<%@ Page Language="C#" ContentType="text/html" %>
<%@ Register TagPrefix="MM" Namespace="DreamweaverCtrls"
Assembly="DreamweaverCtrls,version=1.0.0.0,publicKeyToken=836f606ede05d46a,culture=neutral"
%>
<MM:DataSet
id="dsProductList"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%#
System.Configuration.ConfigurationSettings.AppSettings["MM_CONNECTION_STRING_connCAXaspx"]
%>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings["MM_CONNECTION_DATABASETYPE_connCAXaspx"]
%>'
CommandText='<%# "SELECT * FROM products" %>'
Debug="true"
></MM:DataSet>

<MM:PageBind runat="server" PostBackBind="true" />
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Text" %>
<script language="C#" runat="server">
void Page_Load(object sender, EventArgs e){
XmlTextWriter writer = new XmlTextWriter(Response.OutputStream,
Encoding.UTF8);
writer.WriteStartDocument();
writer.Formatting = Formatting.Indented;
writer.WriteComment("XML Output from ASPX C# Page. Designed by Shaine
Fisher");
writer.WriteStartElement("products");
writer.WriteStartElement("product");
writer.WriteAttributeString("itemname", Request.UserAgent);
writer.WriteAttributeString("id", <%#***
dsProductList.FieldValue("productid", Container) %> );
writer.WriteAttributeString("man", "Kustom Kit");
writer.WriteAttributeString("descsm", "This is a small
description.");
writer.WriteAttributeString("dateadded", "31/07/2004");
writer.WriteAttributeString("price", "10.49");
writer.WriteAttributeString("img", "kk109.jpg");
writer.WriteAttributeString("isnew", "f");
writer.WriteEndElement();
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Close();
}
</script>


There must be a way to do this, I just can't find the solution right
now!!


Cheers

Shaine
Julian Roberts

2004-08-07, 7:15 pm

Try

writer.WriteAttributeString("id",dsProductList.FieldValue("productid",
null));

--
Jules
http://www.charon.co.uk/charoncart
Charon Cart 3
Shopping Cart Extension for Dreamweaver MX/MX 2004


Shaine Fisher

2004-08-08, 7:14 am

"Julian Roberts" <newsg@charon.co.uk> wrote in message news:<cf33co$bum$1@forums.macromedia.com>...
> Try
>
> writer.WriteAttributeString("id",dsProductList.FieldValue("productid",
> null));


Thanks, I'll give that a go.

Shaine
Shaine Fisher

2004-08-08, 7:14 am

"Julian Roberts" <newsg@charon.co.uk> wrote in message news:<cf33co$bum$1@forums.macromedia.com>...
> Try
>
> writer.WriteAttributeString("id",dsProductList.FieldValue("productid",
> null));


These 2 messages may turn up in the worng order, but who cares.
Thanks, that worked, perfect.

Shaine
Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews