Monday, March 26, 2012
HTML form inside a ASP.NET form: CMS
page.
This information is stored in a database and at run-time is displayed inside
a content placeholder (I'm using MasterPages).
The problem I am having is that because .NET places a form tag wth
runat=server my nested HTML tag posts back to the .NET form instead of the
HTML page declared in the action tag of the HTML form.
I have read that the way to get around this is to place the HTML form
outside of the .NET tag but how can I do this when a page is being built
from the database and displayed inside a content placeholder...
Any ideas welcome!
Thanks
MarkMark,
I had the same problem inserting html forms into a masterpage and came up
with this technique witch didn't completely work for me (problems when desig
n
of masterpage changed) so I made a standalone page of html forms. Maybe the
technique will work for you. It involves injecting html form tags into the
client.
In content place holder close out the masterpage form by writing a literal
control to the client
me.controls.add(new literalcontrol("</form>"))
...
Write out your db forms. how ever you do this Mark.
me.controls.add(new MarkFormfromdb)
...
Create dummy header for aspx masterpage closing form tag for well formed htm
l.
me.controls.add(new literalcontrol("<form> ))
Good Luck
DWS
"Mark" wrote:
> Hi all, I have a WYSIWYG editor which allows people to insert a form into
a
> page.
> This information is stored in a database and at run-time is displayed insi
de
> a content placeholder (I'm using MasterPages).
> The problem I am having is that because .NET places a form tag wth
> runat=server my nested HTML tag posts back to the .NET form instead of the
> HTML page declared in the action tag of the HTML form.
> I have read that the way to get around this is to place the HTML form
> outside of the .NET tag but how can I do this when a page is being built
> from the database and displayed inside a content placeholder...
> Any ideas welcome!
> Thanks
> Mark
>
>
>
Hi, thanks for your help, I will give this a go
Cheers
Mark
"DWS" <DWS@.discussions.microsoft.com> wrote in message
news:4E27ABA2-F0C8-4DF6-A49E-948A7D2892B8@.microsoft.com...
> Mark,
> I had the same problem inserting html forms into a masterpage and came up
> with this technique witch didn't completely work for me (problems when
> design
> of masterpage changed) so I made a standalone page of html forms. Maybe
> the
> technique will work for you. It involves injecting html form tags into
> the
> client.
> In content place holder close out the masterpage form by writing a
> literal
> control to the client
> me.controls.add(new literalcontrol("</form>"))
> ...
> Write out your db forms. how ever you do this Mark.
> me.controls.add(new MarkFormfromdb)
> ...
> Create dummy header for aspx masterpage closing form tag for well formed
> html.
> me.controls.add(new literalcontrol("<form> ))
> Good Luck
> DWS
>
> "Mark" wrote:
>
HTML form inside a ASP.NET form: CMS
page.
This information is stored in a database and at run-time is displayed inside
a content placeholder (I'm using MasterPages).
The problem I am having is that because .NET places a form tag wth
runat=server my nested HTML tag posts back to the .NET form instead of the
HTML page declared in the action tag of the HTML form.
I have read that the way to get around this is to place the HTML form
outside of the .NET tag but how can I do this when a page is being built
from the database and displayed inside a content placeholder...
Any ideas welcome!
Thanks
MarkMark,
I had the same problem inserting html forms into a masterpage and came up
with this technique witch didn't completely work for me (problems when design
of masterpage changed) so I made a standalone page of html forms. Maybe the
technique will work for you. It involves injecting html form tags into the
client.
In content place holder close out the masterpage form by writing a literal
control to the client
me.controls.add(new literalcontrol("</form>"))
....
Write out your db forms. how ever you do this Mark.
me.controls.add(new MarkFormfromdb)
...
Create dummy header for aspx masterpage closing form tag for well formed html.
me.controls.add(new literalcontrol("<form>))
Good Luck
DWS
"Mark" wrote:
> Hi all, I have a WYSIWYG editor which allows people to insert a form into a
> page.
> This information is stored in a database and at run-time is displayed inside
> a content placeholder (I'm using MasterPages).
> The problem I am having is that because .NET places a form tag wth
> runat=server my nested HTML tag posts back to the .NET form instead of the
> HTML page declared in the action tag of the HTML form.
> I have read that the way to get around this is to place the HTML form
> outside of the .NET tag but how can I do this when a page is being built
> from the database and displayed inside a content placeholder...
> Any ideas welcome!
> Thanks
> Mark
>
>
>
Hi, thanks for your help, I will give this a go
Cheers
Mark
"DWS" <DWS@.discussions.microsoft.com> wrote in message
news:4E27ABA2-F0C8-4DF6-A49E-948A7D2892B8@.microsoft.com...
> Mark,
> I had the same problem inserting html forms into a masterpage and came up
> with this technique witch didn't completely work for me (problems when
> design
> of masterpage changed) so I made a standalone page of html forms. Maybe
> the
> technique will work for you. It involves injecting html form tags into
> the
> client.
> In content place holder close out the masterpage form by writing a
> literal
> control to the client
> me.controls.add(new literalcontrol("</form>"))
> ...
> Write out your db forms. how ever you do this Mark.
> me.controls.add(new MarkFormfromdb)
> ...
> Create dummy header for aspx masterpage closing form tag for well formed
> html.
> me.controls.add(new literalcontrol("<form>))
> Good Luck
> DWS
>
> "Mark" wrote:
>> Hi all, I have a WYSIWYG editor which allows people to insert a form into
>> a
>> page.
>>
>> This information is stored in a database and at run-time is displayed
>> inside
>> a content placeholder (I'm using MasterPages).
>>
>> The problem I am having is that because .NET places a form tag wth
>> runat=server my nested HTML tag posts back to the .NET form instead of
>> the
>> HTML page declared in the action tag of the HTML form.
>>
>> I have read that the way to get around this is to place the HTML form
>> outside of the .NET tag but how can I do this when a page is being built
>> from the database and displayed inside a content placeholder...
>>
>> Any ideas welcome!
>> Thanks
>> Mark
>>
>>
>>
>>
>>
>
HTML file from database to user interface
I have a html document in a sql server table with tags and elements. I need
to read it from table field and show it in a web page. Is there any
component that I can use to show this html file in the browsed with
interpreting the html tags.Couldn't you just select the rows from the data and write out each raw line
with response.write(<data> )?
"JIM.H." <JIMH@.discussions.microsoft.com> wrote in message
news:10BCEEB4-E71E-43B2-849B-19E71953C348@.microsoft.com...
> HTML file from database to user interface
> I have a html document in a sql server table with tags and elements. I
> need
> to read it from table field and show it in a web page. Is there any
> component that I can use to show this html file in the browsed with
> interpreting the html tags.
>
This page has other components and I need to show this html in the middle
section, I probably need a component that does that.
"bill" wrote:
> Couldn't you just select the rows from the data and write out each raw lin
e
> with response.write(<data> )?
> "JIM.H." <JIMH@.discussions.microsoft.com> wrote in message
> news:10BCEEB4-E71E-43B2-849B-19E71953C348@.microsoft.com...
>
>
You could put this in a literal control making this html fragment appears at
the exact location you want...
Patrice
"JIM.H." <JIMH@.discussions.microsoft.com> a crit dans le message de news:
AF276C5B-8F44-4D1E-B124-33AA23223736@.microsoft.com...
> This page has other components and I need to show this html in the middle
> section, I probably need a component that does that.
> "bill" wrote:
>
I am quite new, can you give me an example pelase?
"Patrice" wrote:
> You could put this in a literal control making this html fragment appears
at
> the exact location you want...
> --
> Patrice
> "JIM.H." <JIMH@.discussions.microsoft.com> a écrit dans le message de news
:
> AF276C5B-8F44-4D1E-B124-33AA23223736@.microsoft.com...
>
>
An example of which part? You just select the data from the database, loop
through the result set, and for each loop you simply put
"response.write(<yourdata> )"...
"JIM.H." <JIMH@.discussions.microsoft.com> wrote in message
news:56642F77-1368-4BFE-82E9-17E35DAD1473@.microsoft.com...
>I am quite new, can you give me an example pelase?
> "Patrice" wrote:
>
Here is some sample/psuedo code. This should give you a good idea of
how to implement this.
<%@. Control ClassName="DataBaseHtmlLiteral" %>
<script runat="server">
Public DataBaseID as integer
Sub OnPreRender
' create sql connection and command
SqlCmd = "Select TOP 1 [Table].[html] from [Table] WHERE [Table].
[IDField] = @.ID"
SqlCmd.Parameters.add("@.ID",DatabaseID)
HTML.Text = DirectCast(SqlCmd.ExecuteScalar(),String)
' clean up (close connection etc.)
End Sub
</script>
<asp:Literal ID="HTML" runat="server" />
Each instance requires the DataBaseID to be set.
This assumes a single instance of the html, if you are looping through
the table, do not use this. Don't want
Also, error catching is needed (row doesn't exist, column is null,
DataBaseID is null, etc)
Hope this helps!
I guess you meant Literal?
JIM. H. wrote:
> HTML file from database to user interface
> I have a html document in a sql server table with tags and elements. I ne
ed
> to read it from table field and show it in a web page. Is there any
> component that I can use to show this html file in the browsed with
> interpreting the html tags.
HTML file from database to user interface
how to implement this.
<%@dotnet.itags.org. Control ClassName="DataBaseHtmlLiteral" %>
<script runat="server">
Public DataBaseID as integer
Sub OnPreRender
' create sql connection and command
SqlCmd = "Select TOP 1 [Table].[html] from [Table] WHERE [Table].
[IDField] = @dotnet.itags.org.ID"
SqlCmd.Parameters.add("@dotnet.itags.org.ID",DatabaseID)
HTML.Text = DirectCast(SqlCmd.ExecuteScalar(),String)
' clean up (close connection etc.)
End Sub
</script>
<asp:Literal ID="HTML" runat="server" />
Each instance requires the DataBaseID to be set.
This assumes a single instance of the html, if you are looping through
the table, do not use this. Don't want
Also, error catching is needed (row doesn't exist, column is null,
DataBaseID is null, etc)
Hope this helps!
Thursday, March 22, 2012
HTML Control and ASP.Net control question
txtaspcontrol.text=myvalue;
same to html text control
txthtmltextcontrol.text=myvalue through asp.net form i am using asp.net 1.1Sure, just make sure your HTML control has the runat=server attribute. Then
you can access it in your code-behind.
-Demetri
"amjad" wrote:
> Hi is there any way to assing database value to html control like
> txtaspcontrol.text=myvalue;
> same to html text control
> txthtmltextcontrol.text=myvalue through asp.net form i am using asp.net 1.
1
>
HTML Control and ASP.Net control question
txtaspcontrol.text=myvalue;
same to html text control
txthtmltextcontrol.text=myvalue through asp.net form i am using asp.net 1.1Sure, just make sure your HTML control has the runat=server attribute. Then
you can access it in your code-behind.
--
-Demetri
"amjad" wrote:
> Hi is there any way to assing database value to html control like
> txtaspcontrol.text=myvalue;
> same to html text control
> txthtmltextcontrol.text=myvalue through asp.net form i am using asp.net 1.1
html content pageing in .net page
hi...
i have a problem and i'm not find in web this problem.
problem: text data recorded in database and this text data content HTML. iwant to pageing this textdata in page. i try count to character but tobe HTML tag in text data... i hope understand me.
Hi. You can try using
Server.HtmlEncode("<b>Your HTML Content Here</b>")
no no i'm not find this. i write problem again : example have a text (3000 character) and i do paging this text. example every page 1000 character... total 3 page. or text = 5000 character every page 1000 character total page = 5 as soon as... this application same datagrip paging ... BUT existent HTML TAGS in text... anyway problem this HTML TAGS...
already now thanks...
HTML Code generation
I was wondering if there is a way to store all the HTML element information
in a database and then dynamically generate the HTML code for a page?..
Basically, I do not want to design every HTML page, instead just define the
elements like "label", "Textbox", "Submit" button etc., in a database and
then have a tool generate the HTML code forme..
Does anyone have any ideas or pointers'
Thanks.That would be tough because the elements are objects, and do not all have
the same properties (a TextBox does not have the same properties as a Label,
for example). If you REALLY wanted to do that (I don't know why you would,
if you know exactly what the HTML will be use a *.html file), create a
database table with 3 fields:
First Field (the primary key): an integer specifying the order of the tags
Second Field: a string that lists the tag (such as input, font, table, etc.)
and attributes or literal content
Third Field: a string that specifies whether the second field is an opening
tag, closing tag, or literal content
The second field would need to be parsed, since it must be all one string
and you cannot have separate fields for the properties since different tags
have different properties. When the third field has a value of 'closingtag'
you can either give the second field an empty string and dynamically
determine what tag it is closing or just give the second field a value of
what the closing tag would look like (</table>, , etc.). However, I
still think that doing this is more work than necessary and that you should
find a better way, if you let us know your reason for wanting to put this
info in a database instead of one of the conventional methods we might be
able to help you find a better and easier way to achieve your goal.
--
Nathan Sokalski
njsokalski@.hotmail.com
http://www.nathansokalski.com/
"Ganesh Muthuvelu" <GaneshMuthuvelu@.discussions.microsoft.com> wrote in
message news:52CA3309-FDA7-4201-AAD0-1728D09D0EE4@.microsoft.com...
> Hello,
> I was wondering if there is a way to store all the HTML element
> information
> in a database and then dynamically generate the HTML code for a page?..
> Basically, I do not want to design every HTML page, instead just define
> the
> elements like "label", "Textbox", "Submit" button etc., in a database and
> then have a tool generate the HTML code forme..
> Does anyone have any ideas or pointers'
> Thanks.
Ganesh,
Certainly you *could* do that; essentially you are describing a means of
assembling a big string full of HTML. But, what would be the point of this?
It would be missing the server-side ASP.NET Page model, events, and
everything else needed for a fully functioning ASP.NET application.
Sounds like a step backwards to me.
Now, if you want to add ASP.NET controls to a page programmatically, that
can certainly be done, and you can "have your cake, and eat it, too".
Peter
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
"Ganesh Muthuvelu" wrote:
> Hello,
> I was wondering if there is a way to store all the HTML element informatio
n
> in a database and then dynamically generate the HTML code for a page?..
> Basically, I do not want to design every HTML page, instead just define th
e
> elements like "label", "Textbox", "Submit" button etc., in a database and
> then have a tool generate the HTML code forme..
> Does anyone have any ideas or pointers'
> Thanks.
Peter,
Yes.. I see what you are saying. Now, is there a way to add ASP .NET
controls dynamically to a page including the layout of the controls as well
as the look & feel?..
Basically, I have a application which pulls data from a 3rd party system and
pushes data back to the same system after the user makes the changes.. All
data are exchanged as "XML".. So, I need to show the data in a neat way to
the user so that the user can change it and send it back..
Since the volume and type of data is so much, I cannot generate a ASPX page
for each XML exchange and hence looking for doing stuff dynamically if the
necessary info is stored in the database about the XML elements..
Any ideas/pointers will be appreciated..
Thanks.
"Peter Bromberg [C# MVP]" wrote:
> Ganesh,
> Certainly you *could* do that; essentially you are describing a means of
> assembling a big string full of HTML. But, what would be the point of this
?
> It would be missing the server-side ASP.NET Page model, events, and
> everything else needed for a fully functioning ASP.NET application.
> Sounds like a step backwards to me.
> Now, if you want to add ASP.NET controls to a page programmatically, that
> can certainly be done, and you can "have your cake, and eat it, too".
> Peter
> --
> Co-founder, Eggheadcafe.com developer portal:
> http://www.eggheadcafe.com
> UnBlog:
> http://petesbloggerama.blogspot.com
>
>
> "Ganesh Muthuvelu" wrote:
>
google "htmltextwriter"
"Ganesh Muthuvelu" <GaneshMuthuvelu@.discussions.microsoft.com> wrote in mess
age
news:52CA3309-FDA7-4201-AAD0-1728D09D0EE4@.microsoft.com...
> Hello,
> I was wondering if there is a way to store all the HTML element informatio
n
> in a database and then dynamically generate the HTML code for a page?..
> Basically, I do not want to design every HTML page, instead just define th
e
> elements like "label", "Textbox", "Submit" button etc., in a database and
> then have a tool generate the HTML code forme..
> Does anyone have any ideas or pointers'
> Thanks.
HTML Code generation
I was wondering if there is a way to store all the HTML element information
in a database and then dynamically generate the HTML code for a page?..
Basically, I do not want to design every HTML page, instead just define the
elements like "label", "Textbox", "Submit" button etc., in a database and
then have a tool generate the HTML code forme..
Does anyone have any ideas or pointers??
Thanks.That would be tough because the elements are objects, and do not all have
the same properties (a TextBox does not have the same properties as a Label,
for example). If you REALLY wanted to do that (I don't know why you would,
if you know exactly what the HTML will be use a *.html file), create a
database table with 3 fields:
First Field (the primary key): an integer specifying the order of the tags
Second Field: a string that lists the tag (such as input, font, table, etc.)
and attributes or literal content
Third Field: a string that specifies whether the second field is an opening
tag, closing tag, or literal content
The second field would need to be parsed, since it must be all one string
and you cannot have separate fields for the properties since different tags
have different properties. When the third field has a value of 'closingtag'
you can either give the second field an empty string and dynamically
determine what tag it is closing or just give the second field a value of
what the closing tag would look like (</table>, </font>, etc.). However, I
still think that doing this is more work than necessary and that you should
find a better way, if you let us know your reason for wanting to put this
info in a database instead of one of the conventional methods we might be
able to help you find a better and easier way to achieve your goal.
--
Nathan Sokalski
njsokalski@.hotmail.com
http://www.nathansokalski.com/
"Ganesh Muthuvelu" <GaneshMuthuvelu@.discussions.microsoft.com> wrote in
message news:52CA3309-FDA7-4201-AAD0-1728D09D0EE4@.microsoft.com...
> Hello,
> I was wondering if there is a way to store all the HTML element
> information
> in a database and then dynamically generate the HTML code for a page?..
> Basically, I do not want to design every HTML page, instead just define
> the
> elements like "label", "Textbox", "Submit" button etc., in a database and
> then have a tool generate the HTML code forme..
> Does anyone have any ideas or pointers??
> Thanks.
Ganesh,
Certainly you *could* do that; essentially you are describing a means of
assembling a big string full of HTML. But, what would be the point of this?
It would be missing the server-side ASP.NET Page model, events, and
everything else needed for a fully functioning ASP.NET application.
Sounds like a step backwards to me.
Now, if you want to add ASP.NET controls to a page programmatically, that
can certainly be done, and you can "have your cake, and eat it, too".
Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
"Ganesh Muthuvelu" wrote:
> Hello,
> I was wondering if there is a way to store all the HTML element information
> in a database and then dynamically generate the HTML code for a page?..
> Basically, I do not want to design every HTML page, instead just define the
> elements like "label", "Textbox", "Submit" button etc., in a database and
> then have a tool generate the HTML code forme..
> Does anyone have any ideas or pointers??
> Thanks.
Peter,
Yes.. I see what you are saying. Now, is there a way to add ASP .NET
controls dynamically to a page including the layout of the controls as well
as the look & feel?..
Basically, I have a application which pulls data from a 3rd party system and
pushes data back to the same system after the user makes the changes.. All
data are exchanged as "XML".. So, I need to show the data in a neat way to
the user so that the user can change it and send it back..
Since the volume and type of data is so much, I cannot generate a ASPX page
for each XML exchange and hence looking for doing stuff dynamically if the
necessary info is stored in the database about the XML elements..
Any ideas/pointers will be appreciated..
Thanks.
"Peter Bromberg [C# MVP]" wrote:
> Ganesh,
> Certainly you *could* do that; essentially you are describing a means of
> assembling a big string full of HTML. But, what would be the point of this?
> It would be missing the server-side ASP.NET Page model, events, and
> everything else needed for a fully functioning ASP.NET application.
> Sounds like a step backwards to me.
> Now, if you want to add ASP.NET controls to a page programmatically, that
> can certainly be done, and you can "have your cake, and eat it, too".
> Peter
> --
> Co-founder, Eggheadcafe.com developer portal:
> http://www.eggheadcafe.com
> UnBlog:
> http://petesbloggerama.blogspot.com
>
>
> "Ganesh Muthuvelu" wrote:
> > Hello,
> > I was wondering if there is a way to store all the HTML element information
> > in a database and then dynamically generate the HTML code for a page?..
> > Basically, I do not want to design every HTML page, instead just define the
> > elements like "label", "Textbox", "Submit" button etc., in a database and
> > then have a tool generate the HTML code forme..
> > Does anyone have any ideas or pointers??
> > Thanks.
google "htmltextwriter"
"Ganesh Muthuvelu" <GaneshMuthuvelu@.discussions.microsoft.com> wrote in message
news:52CA3309-FDA7-4201-AAD0-1728D09D0EE4@.microsoft.com...
> Hello,
> I was wondering if there is a way to store all the HTML element information
> in a database and then dynamically generate the HTML code for a page?..
> Basically, I do not want to design every HTML page, instead just define the
> elements like "label", "Textbox", "Submit" button etc., in a database and
> then have a tool generate the HTML code forme..
> Does anyone have any ideas or pointers??
> Thanks.
Wednesday, March 21, 2012
HTML Clean up
The idea was to save formatted html for each news article directly to the database, which is then displayed on the article table.
this idea worked fine, but unfortunatly people are using dreamweaver, ms word, and the like to create this html.
Needless to say, nearly 25,000 articles in my database by now, the article table alone grew to about 650MB (80% of the database!).
So I'm going to create a new component for them to create articles.
but, while doing so, I was wondering if there is something one can do, to loop through the database and "clean up" the html or something?
Worse case scenario, i will just leave the existing articles as is, and new articles will have simple html, with a single stylesheet for all articles.
Just would have like to clean up existing articles. That messy htlm, and huge record are crippling the search functionality.You will need to know what sort of 'extra' features these web editors add. You can then use a regex search to go through all the records and remove them (without removing the innertext). You could use SQL for this by directly manipulating the database.
Don't forget to try it on a backup first.
Html calling apsx - How to pass in a variable value?
Showmerecords.aspx connects to a database and retrieves a subset of data based on a criteria. I want the criteria to be contained within the splashscreen call to the showmerecords.aspx.
If the criterias were "Green Baloons", "Red Baloons", "Yellow Baloons" I would want to have it like something like this:
<P>Providers</P>
<P>Providers</P>
<P>Providers</P
How can I write the apsx to accept the text value from the call?
In the aspx I would like to construct a sql call string like this:
"select from baloons where balooncolor = " & BaloonColorVar
I hope I have explained my intention clearly. Thanks to anyone for help.
Green Balloons
C#
"select from balloons where balloonColor = " + Request.QueryString["color"];VB
"select from balloons where balloonColor = " & Request.QueryString("color")
USe your links like this:
'Green Baloons Providers
Then in your aspx you can check the querysting
in c#
"select from baloons where balooncolor = " + Request.QueryString["color"]
I am replying to an older thread.
I was wondering whether it is possible to pass more than 1 variable?
could you for example do something like
'Green Baloons Providers
effectively passing two variables. One is called provider and the second one is called QueryServer
Thanks for the information.
html at end of download - urgent please help!
i have the following bit of code that downloads/uploads documents from
a sql database.
the problem i have is when i download an image for example and look at
it in notepad i see the binary data and below it the html from the page
the image was downloaded from. so my 10k image is now 32k.
please any help would be much appreciated.
thanks
shawn
Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnUpload.Click
Dim iLength As Integer =
CType(LifeFileUpload.PostedFile.InputStream.Length , Integer)
If iLength = 0 Then Exit Sub 'not a valid file
Dim sContentType As String =
LifeFileUpload.PostedFile.ContentType
Dim sFileName As String, i As Integer
Dim bytContent As Byte()
ReDim bytContent(iLength)
'strip the path off the filename
i = InStrRev(LifeFileUpload.PostedFile.FileName.Trim, "\")
If i = 0 Then
sFileName = LifeFileUpload.PostedFile.FileName.Trim
Else
sFileName = Right(LifeFileUpload.PostedFile.FileName.Trim,
Len(LifeFileUpload.PostedFile.FileName.Trim) - i)
End If
LifeFileUpload.PostedFile.InputStream.Read(bytCont ent, 0,
iLength)
objDonkey.SelectedClient.AddDocument(objDonkey.Use rName,
sFileName, sContentType, iLength, bytContent, "this is a test
document")
End Sub
Protected Sub btnGetDoc_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnGetDoc.Click
Dim DocId As Integer
Dim objDoc As Life.Clients.Client.DocumentItem
DocId = HiddenSelectedDoc.Value
objDonkey.SelectedClient.GetDocuments()
objDoc = objDonkey.SelectedClient.DocumentList(DocId)
Response.Buffer = True
Response.Expires = -1
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "image/jpeg" 'objDoc.ContentType
Response.OutputStream.Write(CType(objDonkey.Select edClient.GetDocument(DocId),
Byte()), 0, CInt(objDoc.ContentLegnth))
Response.AddHeader("Content-Disposition",
"attachment;filename=" + objDoc.Filename)
Response.Flush()
End SubHi Shawn,
Try to clear the response object after the following code:
Response.Buffer = True
Response.Expires = -1
Response.ClearContent()
Response.ClearHeaders()
// Clear the response object.
Response.Clear();
And then when you finished writing into the response stream:
Response.Flush();
Response.End();
I think it might help.
See ya.
Thiago Oliveira
shawn_vandenberg@.yahoo.com escreveu:
Quote:
Originally Posted by
hi there
>
i have the following bit of code that downloads/uploads documents from
a sql database.
>
the problem i have is when i download an image for example and look at
it in notepad i see the binary data and below it the html from the page
the image was downloaded from. so my 10k image is now 32k.
>
please any help would be much appreciated.
>
thanks
>
shawn
>
>
>
Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnUpload.Click
Dim iLength As Integer =
CType(LifeFileUpload.PostedFile.InputStream.Length , Integer)
If iLength = 0 Then Exit Sub 'not a valid file
Dim sContentType As String =
LifeFileUpload.PostedFile.ContentType
Dim sFileName As String, i As Integer
Dim bytContent As Byte()
ReDim bytContent(iLength)
>
'strip the path off the filename
i = InStrRev(LifeFileUpload.PostedFile.FileName.Trim, "\")
If i = 0 Then
sFileName = LifeFileUpload.PostedFile.FileName.Trim
Else
sFileName = Right(LifeFileUpload.PostedFile.FileName.Trim,
Len(LifeFileUpload.PostedFile.FileName.Trim) - i)
End If
>
LifeFileUpload.PostedFile.InputStream.Read(bytCont ent, 0,
iLength)
>
objDonkey.SelectedClient.AddDocument(objDonkey.Use rName,
sFileName, sContentType, iLength, bytContent, "this is a test
document")
>
>
End Sub
>
Protected Sub btnGetDoc_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnGetDoc.Click
Dim DocId As Integer
Dim objDoc As Life.Clients.Client.DocumentItem
>
DocId = HiddenSelectedDoc.Value
objDonkey.SelectedClient.GetDocuments()
objDoc = objDonkey.SelectedClient.DocumentList(DocId)
>
>
Response.Buffer = True
Response.Expires = -1
Response.ClearContent()
Response.ClearHeaders()
>
Response.ContentType = "image/jpeg" 'objDoc.ContentType
>
Response.OutputStream.Write(CType(objDonkey.Select edClient.GetDocument(DocId),
Byte()), 0, CInt(objDoc.ContentLegnth))
Response.AddHeader("Content-Disposition",
"attachment;filename=" + objDoc.Filename)
Response.Flush()
>
>
End Sub
html at end of download - urgent please help!
i have the following bit of code that downloads/uploads documents from
a sql database.
the problem i have is when i download an image for example and look at
it in notepad i see the binary data and below it the html from the page
the image was downloaded from. so my 10k image is now 32k.
please any help would be much appreciated.
thanks
shawn
Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnUpload.Click
Dim iLength As Integer =
CType(LifeFileUpload.PostedFile.InputStream.Length, Integer)
If iLength = 0 Then Exit Sub 'not a valid file
Dim sContentType As String =
LifeFileUpload.PostedFile.ContentType
Dim sFileName As String, i As Integer
Dim bytContent As Byte()
ReDim bytContent(iLength)
'strip the path off the filename
i = InStrRev(LifeFileUpload.PostedFile.FileName.Trim, "\")
If i = 0 Then
sFileName = LifeFileUpload.PostedFile.FileName.Trim
Else
sFileName = Right(LifeFileUpload.PostedFile.FileName.Trim,
Len(LifeFileUpload.PostedFile.FileName.Trim) - i)
End If
LifeFileUpload.PostedFile.InputStream.Read(bytContent, 0,
iLength)
objDonkey.SelectedClient.AddDocument(objDonkey.UserName,
sFileName, sContentType, iLength, bytContent, "this is a test
document")
End Sub
Protected Sub btnGetDoc_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnGetDoc.Click
Dim DocId As Integer
Dim objDoc As Life.Clients.Client.DocumentItem
DocId = HiddenSelectedDoc.Value
objDonkey.SelectedClient.GetDocuments()
objDoc = objDonkey.SelectedClient.DocumentList(DocId)
Response.Buffer = True
Response.Expires = -1
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "image/jpeg" 'objDoc.ContentType
Response.OutputStream.Write(CType(objDonkey.SelectedClient.GetDocument(DocId
),
Byte()), 0, CInt(objDoc.ContentLegnth))
Response.AddHeader("Content-Disposition",
"attachment;filename=" + objDoc.Filename)
Response.Flush()
End SubHi Shawn,
Try to clear the response object after the following code:
Response.Buffer = True
Response.Expires = -1
Response.ClearContent()
Response.ClearHeaders()
// Clear the response object.
Response.Clear();
And then when you finished writing into the response stream:
Response.Flush();
Response.End();
I think it might help.
See ya.
Thiago Oliveira
shawn_vandenberg@.yahoo.com escreveu:
> hi there
> i have the following bit of code that downloads/uploads documents from
> a sql database.
> the problem i have is when i download an image for example and look at
> it in notepad i see the binary data and below it the html from the page
> the image was downloaded from. so my 10k image is now 32k.
> please any help would be much appreciated.
> thanks
> shawn
>
> Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles btnUpload.Click
> Dim iLength As Integer =
> CType(LifeFileUpload.PostedFile.InputStream.Length, Integer)
> If iLength = 0 Then Exit Sub 'not a valid file
> Dim sContentType As String =
> LifeFileUpload.PostedFile.ContentType
> Dim sFileName As String, i As Integer
> Dim bytContent As Byte()
> ReDim bytContent(iLength)
> 'strip the path off the filename
> i = InStrRev(LifeFileUpload.PostedFile.FileName.Trim, "\")
> If i = 0 Then
> sFileName = LifeFileUpload.PostedFile.FileName.Trim
> Else
> sFileName = Right(LifeFileUpload.PostedFile.FileName.Trim,
> Len(LifeFileUpload.PostedFile.FileName.Trim) - i)
> End If
> LifeFileUpload.PostedFile.InputStream.Read(bytContent, 0,
> iLength)
> objDonkey.SelectedClient.AddDocument(objDonkey.UserName,
> sFileName, sContentType, iLength, bytContent, "this is a test
> document")
>
> End Sub
> Protected Sub btnGetDoc_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles btnGetDoc.Click
> Dim DocId As Integer
> Dim objDoc As Life.Clients.Client.DocumentItem
> DocId = HiddenSelectedDoc.Value
> objDonkey.SelectedClient.GetDocuments()
> objDoc = objDonkey.SelectedClient.DocumentList(DocId)
>
> Response.Buffer = True
> Response.Expires = -1
> Response.ClearContent()
> Response.ClearHeaders()
> Response.ContentType = "image/jpeg" 'objDoc.ContentType
> Response.OutputStream.Write(CType(objDonkey.SelectedClient.GetDocument(Doc
Id),
> Byte()), 0, CInt(objDoc.ContentLegnth))
> Response.AddHeader("Content-Disposition",
> "attachment;filename=" + objDoc.Filename)
> Response.Flush()
>
> End Sub