Uploading File w/o HtmlInputFile control

G

Grant Harmeyer

I have an application that uses FreeTextBox 2.0
(http://www.freetextbox.com). FreeTextBox is a rich text editor that behaves
similarly to MS Word. The FreeTextBox control has a button to insert images
(just as you would with MS Word) and it works beautifully. The problem is
that when you include an image with the rich text editor, the image path is
the local path on the client. I have written a method that examines the text
for <img> tags, extracts the local path, and then replaces it with what the
virtual path will be after the file has been saved to the server.

I would like post the file to the server as I would with an HtmlInputFile
(PostedFile) control using the HttpPostedFile object, but it would appear
that this is not allowed. After doing some digging, it looks like my best
option would be to write a Web Service that accepts the image as a byte
array and use the WebClient object to upload the file to the service.

It sounds like this would work but I don't really know how to approach this.
I would rather just straight post the file to the HttpPostedFileCollection
just like an HtmlInputFile control does, but that doesn't look like a
possible option. If anyone knows a good means to upload a file without the
HtmlInputFile control, please let me know.

TIA,

Grant Harmeyer
 
H

Hermit Dave

what do you mean the htmlinput file is not allowed ?
i have used that object with freetextbox. have a look at this

<form id="Form1" method="post" runat="server">
<table cellSpacing="0" cellPadding="3" width="700" border="0">
<tr>
<td><uc1:moduletitle id="ModuleTitle1" runat="server"
DisplayText="Email Users"></uc1:moduletitle></td>
</tr>
<tr>
<td vAlign="top" align="left"><b>Mailer&nbsp;Subject</b></td>
<td><asp:requiredfieldvalidator id="RFVSubject" runat="server"
Display="Dynamic" ControlToValidate="txtSubject"
ErrorMessage="Subject Required">*</asp:requiredfieldvalidator></td>
</tr>
<tr>
<td colSpan="2"><asp:textbox id="txtSubject" runat="server"
MaxLength="100" Columns="50" Width="600px"></asp:textbox></td>
</tr>
<tr>
<td vAlign="top" align="left"><b>Mailer Body</b></td>
<td><asp:requiredfieldvalidator id="RFVBody" runat="server"
Display="Dynamic" ControlToValidate="txtBody" ErrorMessage="Item Text
Required">*</asp:requiredfieldvalidator></td>
</tr>
<tr>
<td colSpan="2"><FTB:FREETEXTBOX id="txtBody" runat="server"
Width="600px" BreakMode="LineBreak" DownLevelCols="50"

ToolbarLayout="paragraphmenu,fontsizesmenu,FontForeColorsMenu,FontBackColors
Menu|bold,italic,underline,Strikethrough, Superscript,
Subscript;JustifyLeft, JustifyRight, JustifyCenter,
JustifyFull;bulletedlist,numberedlist;CreateLink, Unlink; Cut, Copy, Paste,
Undo, Redo"></FTB:FREETEXTBOX></td>
</tr>
<tr>
<td colSpan="2"><b>Mailer&nbsp;Image Navigation URL</b></td>
</tr>
<tr>
<td>
<asp:TextBox id="txtNavigateURL" runat="server" Width="600px"
Columns="50" MaxLength="200"></asp:TextBox>
</td>
<td>
<asp:RegularExpressionValidator id="REVNavigateURL" runat="server"
ErrorMessage="Invalid URL for Image Navigation"
ControlToValidate="txtNavigateURL" Display="Dynamic"
ValidationExpression="http://([\w-]+\.)+[\w-]+(/[\w-
../?%&amp;=]*)?">*</asp:RegularExpressionValidator></td>
</tr>
<tr>
<td colSpan="2"><b>Mailer&nbsp;Image</b></td>
</tr>
<tr>
<td colSpan="2">
<asp:Image id="imgMainImage" runat="server"></asp:Image></td>
</tr>
<tr>
<td colSpan="2"><INPUT id="uploadMainImage" style="WIDTH: 600px"
type="file" size="80" runat="server">
</td>
</tr>
<tr>
<td colSpan="2">&nbsp;</td>
</tr>
<tr>
<td colSpan="2"><aspzone:eek:neclickbutton id="btnSubmit" runat="server"
Text="Submit"></aspzone:eek:neclickbutton>&nbsp;&nbsp;&nbsp;&nbsp;
<asp:button id="btnCancel" runat="server" Text="Cancel"
CausesValidation="False"></asp:button><asp:validationsummary
id="ValidationSummary1" runat="server" HeaderText="Errors!! Please correct
the following:"
ShowSummary="False" ShowMessageBox="True"></asp:validationsummary>
</td>
</tr>
</table>
</form>

from code behind

if(Page.IsValid)
{
HttpFileCollection myFiles = Request.Files;
HttpPostedFile myFile = myFiles[0];

MailingListDB mlDB = new MailingListDB();
if((bool)ViewState["isAdd"] == true)
{
mlDB.AddNewMailer(txtSubject.Text.Trim(), txtBody.Text,
txtNavigateURL.Text.Trim(), ref myFile);
}
else
{
mlDB.UpdateExistingMailer((int)ViewState["MailerID"],
txtSubject.Text.Trim(), txtBody.Text, txtNavigateURL.Text.Trim(), ref
myFile);
}

if(ViewState["URLReferrer"] != null)
{
Response.Redirect(Convert.ToString(ViewState["URLReferrer"]));
}
else
{
Response.Redirect("~");
}
}

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
 
G

Grant Harmeyer

Bad choice of wording on my part, I apologize. Yes the HtmlInputFile control
is allowed, but it doesn't make much sense to have an HtmlFileInput control
on the WebForm for the images that the FreeTextBox control inserts into the
"Text" property. The "Text" property of the FreeTextBox object may contain
several <img> tags, so a single HtmlInputFile control doesn't make much
sense, unless I want to limit users on the placement and number of images
that are allowed.

Again, I apologize if my wording from this post or the previous post seemed
confusing. Thanks for the help.

Grant

Hermit Dave said:
what do you mean the htmlinput file is not allowed ?
i have used that object with freetextbox. have a look at this

<form id="Form1" method="post" runat="server">
<table cellSpacing="0" cellPadding="3" width="700" border="0">
<tr>
<td><uc1:moduletitle id="ModuleTitle1" runat="server"
DisplayText="Email Users"></uc1:moduletitle></td>
</tr>
<tr>
<td vAlign="top" align="left"><b>Mailer&nbsp;Subject</b></td>
<td><asp:requiredfieldvalidator id="RFVSubject" runat="server"
Display="Dynamic" ControlToValidate="txtSubject"
ErrorMessage="Subject Required">*</asp:requiredfieldvalidator></td>
</tr>
<tr>
<td colSpan="2"><asp:textbox id="txtSubject" runat="server"
MaxLength="100" Columns="50" Width="600px"></asp:textbox></td>
</tr>
<tr>
<td vAlign="top" align="left"><b>Mailer Body</b></td>
<td><asp:requiredfieldvalidator id="RFVBody" runat="server"
Display="Dynamic" ControlToValidate="txtBody" ErrorMessage="Item Text
Required">*</asp:requiredfieldvalidator></td>
</tr>
<tr>
<td colSpan="2"><FTB:FREETEXTBOX id="txtBody" runat="server"
Width="600px" BreakMode="LineBreak" DownLevelCols="50"

ToolbarLayout="paragraphmenu,fontsizesmenu,FontForeColorsMenu,FontBackColors
Menu|bold,italic,underline,Strikethrough, Superscript,
Subscript;JustifyLeft, JustifyRight, JustifyCenter,
JustifyFull;bulletedlist,numberedlist;CreateLink, Unlink; Cut, Copy,
Paste,
Undo, Redo"></FTB:FREETEXTBOX></td>
</tr>
<tr>
<td colSpan="2"><b>Mailer&nbsp;Image Navigation URL</b></td>
</tr>
<tr>
<td>
<asp:TextBox id="txtNavigateURL" runat="server" Width="600px"
Columns="50" MaxLength="200"></asp:TextBox>
</td>
<td>
<asp:RegularExpressionValidator id="REVNavigateURL" runat="server"
ErrorMessage="Invalid URL for Image Navigation"
ControlToValidate="txtNavigateURL" Display="Dynamic"
ValidationExpression="http://([\w-]+\.)+[\w-]+(/[\w-
./?%&amp;=]*)?">*</asp:RegularExpressionValidator></td>
</tr>
<tr>
<td colSpan="2"><b>Mailer&nbsp;Image</b></td>
</tr>
<tr>
<td colSpan="2">
<asp:Image id="imgMainImage" runat="server"></asp:Image></td>
</tr>
<tr>
<td colSpan="2"><INPUT id="uploadMainImage" style="WIDTH: 600px"
type="file" size="80" runat="server">
</td>
</tr>
<tr>
<td colSpan="2">&nbsp;</td>
</tr>
<tr>
<td colSpan="2"><aspzone:eek:neclickbutton id="btnSubmit" runat="server"
Text="Submit"></aspzone:eek:neclickbutton>&nbsp;&nbsp;&nbsp;&nbsp;
<asp:button id="btnCancel" runat="server" Text="Cancel"
CausesValidation="False"></asp:button><asp:validationsummary
id="ValidationSummary1" runat="server" HeaderText="Errors!! Please correct
the following:"
ShowSummary="False" ShowMessageBox="True"></asp:validationsummary>
</td>
</tr>
</table>
</form>

from code behind

if(Page.IsValid)
{
HttpFileCollection myFiles = Request.Files;
HttpPostedFile myFile = myFiles[0];

MailingListDB mlDB = new MailingListDB();
if((bool)ViewState["isAdd"] == true)
{
mlDB.AddNewMailer(txtSubject.Text.Trim(), txtBody.Text,
txtNavigateURL.Text.Trim(), ref myFile);
}
else
{
mlDB.UpdateExistingMailer((int)ViewState["MailerID"],
txtSubject.Text.Trim(), txtBody.Text, txtNavigateURL.Text.Trim(), ref
myFile);
}

if(ViewState["URLReferrer"] != null)
{
Response.Redirect(Convert.ToString(ViewState["URLReferrer"]));
}
else
{
Response.Redirect("~");
}
}

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
Grant Harmeyer said:
I have an application that uses FreeTextBox 2.0
(http://www.freetextbox.com). FreeTextBox is a rich text editor that behaves
similarly to MS Word. The FreeTextBox control has a button to insert images
(just as you would with MS Word) and it works beautifully. The problem is
that when you include an image with the rich text editor, the image path is
the local path on the client. I have written a method that examines the text
for <img> tags, extracts the local path, and then replaces it with what the
virtual path will be after the file has been saved to the server.

I would like post the file to the server as I would with an HtmlInputFile
(PostedFile) control using the HttpPostedFile object, but it would appear
that this is not allowed. After doing some digging, it looks like my best
option would be to write a Web Service that accepts the image as a byte
array and use the WebClient object to upload the file to the service.

It sounds like this would work but I don't really know how to approach this.
I would rather just straight post the file to the
HttpPostedFileCollection
just like an HtmlInputFile control does, but that doesn't look like a
possible option. If anyone knows a good means to upload a file without
the
HtmlInputFile control, please let me know.

TIA,

Grant Harmeyer
 
H

Hermit Dave

well i had a similar problem, the problem is that once on clients page.. the
code is static unless the user posts it.. and there's no way to determine
how many images the user's trying to upload

i would suggest is either limit the number of images or provide a seperate
page for images to uploaded.. ie the user adds the text with placeholders
and then uploads corresponding images seperately.. then you could replace
the placeholders with images at appropriate places.

hth

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
Grant Harmeyer said:
Bad choice of wording on my part, I apologize. Yes the HtmlInputFile control
is allowed, but it doesn't make much sense to have an HtmlFileInput control
on the WebForm for the images that the FreeTextBox control inserts into the
"Text" property. The "Text" property of the FreeTextBox object may contain
several <img> tags, so a single HtmlInputFile control doesn't make much
sense, unless I want to limit users on the placement and number of images
that are allowed.

Again, I apologize if my wording from this post or the previous post seemed
confusing. Thanks for the help.

Grant

Hermit Dave said:
what do you mean the htmlinput file is not allowed ?
i have used that object with freetextbox. have a look at this

<form id="Form1" method="post" runat="server">
<table cellSpacing="0" cellPadding="3" width="700" border="0">
<tr>
<td><uc1:moduletitle id="ModuleTitle1" runat="server"
DisplayText="Email Users"></uc1:moduletitle></td>
</tr>
<tr>
<td vAlign="top" align="left"><b>Mailer&nbsp;Subject</b></td>
<td><asp:requiredfieldvalidator id="RFVSubject" runat="server"
Display="Dynamic" ControlToValidate="txtSubject"
ErrorMessage="Subject
Required">* said:
</tr>
<tr>
<td colSpan="2"><asp:textbox id="txtSubject" runat="server"
MaxLength="100" Columns="50" Width="600px"></asp:textbox></td>
</tr>
<tr>
<td vAlign="top" align="left"><b>Mailer Body</b></td>
<td><asp:requiredfieldvalidator id="RFVBody" runat="server"
Display="Dynamic" ControlToValidate="txtBody" ErrorMessage="Item Text
Required">*</asp:requiredfieldvalidator></td>
</tr>
<tr>
<td colSpan="2"><FTB:FREETEXTBOX id="txtBody" runat="server"
Width="600px" BreakMode="LineBreak" DownLevelCols="50"

ToolbarLayout="paragraphmenu,fontsizesmenu,FontForeColorsMenu,FontBackColors
Menu|bold,italic,underline,Strikethrough, Superscript,
Subscript;JustifyLeft, JustifyRight, JustifyCenter,
JustifyFull;bulletedlist,numberedlist;CreateLink, Unlink; Cut, Copy,
Paste,
Undo, Redo"></FTB:FREETEXTBOX></td>
</tr>
<tr>
<td colSpan="2"><b>Mailer&nbsp;Image Navigation URL</b></td>
</tr>
<tr>
<td>
<asp:TextBox id="txtNavigateURL" runat="server" Width="600px"
Columns="50" MaxLength="200"></asp:TextBox>
</td>
<td>
<asp:RegularExpressionValidator id="REVNavigateURL" runat="server"
ErrorMessage="Invalid URL for Image Navigation"
ControlToValidate="txtNavigateURL" Display="Dynamic"
ValidationExpression="http://([\w-]+\.)+[\w-]+(/[\w-
./?%&amp;=]*)?">*</asp:RegularExpressionValidator></td>
</tr>
<tr>
<td colSpan="2"><b>Mailer&nbsp;Image</b></td>
</tr>
<tr>
<td colSpan="2">
<asp:Image id="imgMainImage" runat="server"></asp:Image></td>
</tr>
<tr>
<td colSpan="2"><INPUT id="uploadMainImage" style="WIDTH: 600px"
type="file" size="80" runat="server">
</td>
</tr>
<tr>
<td colSpan="2">&nbsp;</td>
</tr>
<tr>
<td colSpan="2"><aspzone:eek:neclickbutton id="btnSubmit" runat="server"
Text="Submit"></aspzone:eek:neclickbutton>&nbsp;&nbsp;&nbsp;&nbsp;
<asp:button id="btnCancel" runat="server" Text="Cancel"
CausesValidation="False"></asp:button><asp:validationsummary
id="ValidationSummary1" runat="server" HeaderText="Errors!! Please correct
the following:"
ShowSummary="False" ShowMessageBox="True"></asp:validationsummary>
</td>
</tr>
</table>
</form>

from code behind

if(Page.IsValid)
{
HttpFileCollection myFiles = Request.Files;
HttpPostedFile myFile = myFiles[0];

MailingListDB mlDB = new MailingListDB();
if((bool)ViewState["isAdd"] == true)
{
mlDB.AddNewMailer(txtSubject.Text.Trim(), txtBody.Text,
txtNavigateURL.Text.Trim(), ref myFile);
}
else
{
mlDB.UpdateExistingMailer((int)ViewState["MailerID"],
txtSubject.Text.Trim(), txtBody.Text, txtNavigateURL.Text.Trim(), ref
myFile);
}

if(ViewState["URLReferrer"] != null)
{
Response.Redirect(Convert.ToString(ViewState["URLReferrer"]));
}
else
{
Response.Redirect("~");
}
}

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
Grant Harmeyer said:
I have an application that uses FreeTextBox 2.0
(http://www.freetextbox.com). FreeTextBox is a rich text editor that behaves
similarly to MS Word. The FreeTextBox control has a button to insert images
(just as you would with MS Word) and it works beautifully. The problem is
that when you include an image with the rich text editor, the image
path
is
the local path on the client. I have written a method that examines the text
for <img> tags, extracts the local path, and then replaces it with what the
virtual path will be after the file has been saved to the server.

I would like post the file to the server as I would with an HtmlInputFile
(PostedFile) control using the HttpPostedFile object, but it would appear
that this is not allowed. After doing some digging, it looks like my best
option would be to write a Web Service that accepts the image as a byte
array and use the WebClient object to upload the file to the service.

It sounds like this would work but I don't really know how to approach this.
I would rather just straight post the file to the
HttpPostedFileCollection
just like an HtmlInputFile control does, but that doesn't look like a
possible option. If anyone knows a good means to upload a file without
the
HtmlInputFile control, please let me know.

TIA,

Grant Harmeyer
 
H

Hermit Dave

or once the user posts the data you could do a scan and redirect a form to
the user which auto submits on load. this for you can have all the parsed
images within htmlfileinput control.

give it a try.

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
Hermit Dave said:
well i had a similar problem, the problem is that once on clients page..
the
code is static unless the user posts it.. and there's no way to determine
how many images the user's trying to upload

i would suggest is either limit the number of images or provide a seperate
page for images to uploaded.. ie the user adds the text with placeholders
and then uploads corresponding images seperately.. then you could replace
the placeholders with images at appropriate places.

hth

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
Grant Harmeyer said:
Bad choice of wording on my part, I apologize. Yes the HtmlInputFile control
is allowed, but it doesn't make much sense to have an HtmlFileInput control
on the WebForm for the images that the FreeTextBox control inserts into the
"Text" property. The "Text" property of the FreeTextBox object may
contain
several <img> tags, so a single HtmlInputFile control doesn't make much
sense, unless I want to limit users on the placement and number of images
that are allowed.

Again, I apologize if my wording from this post or the previous post seemed
confusing. Thanks for the help.

Grant

Hermit Dave said:
what do you mean the htmlinput file is not allowed ?
i have used that object with freetextbox. have a look at this

<form id="Form1" method="post" runat="server">
<table cellSpacing="0" cellPadding="3" width="700" border="0">
<tr>
<td><uc1:moduletitle id="ModuleTitle1" runat="server"
DisplayText="Email Users"></uc1:moduletitle></td>
</tr>
<tr>
<td vAlign="top" align="left"><b>Mailer&nbsp;Subject</b></td>
<td><asp:requiredfieldvalidator id="RFVSubject" runat="server"
Display="Dynamic" ControlToValidate="txtSubject"
ErrorMessage="Subject
Required">* said:
</tr>
<tr>
<td colSpan="2"><asp:textbox id="txtSubject" runat="server"
MaxLength="100" Columns="50" Width="600px"></asp:textbox></td>
</tr>
<tr>
<td vAlign="top" align="left"><b>Mailer Body</b></td>
<td><asp:requiredfieldvalidator id="RFVBody" runat="server"
Display="Dynamic" ControlToValidate="txtBody" ErrorMessage="Item Text
Required">*</asp:requiredfieldvalidator></td>
</tr>
<tr>
<td colSpan="2"><FTB:FREETEXTBOX id="txtBody" runat="server"
Width="600px" BreakMode="LineBreak" DownLevelCols="50"

ToolbarLayout="paragraphmenu,fontsizesmenu,FontForeColorsMenu,FontBackColors
Menu|bold,italic,underline,Strikethrough, Superscript,
Subscript;JustifyLeft, JustifyRight, JustifyCenter,
JustifyFull;bulletedlist,numberedlist;CreateLink, Unlink; Cut, Copy,
Paste,
Undo, Redo"></FTB:FREETEXTBOX></td>
</tr>
<tr>
<td colSpan="2"><b>Mailer&nbsp;Image Navigation URL</b></td>
</tr>
<tr>
<td>
<asp:TextBox id="txtNavigateURL" runat="server" Width="600px"
Columns="50" MaxLength="200"></asp:TextBox>
</td>
<td>
<asp:RegularExpressionValidator id="REVNavigateURL" runat="server"
ErrorMessage="Invalid URL for Image Navigation"
ControlToValidate="txtNavigateURL" Display="Dynamic"
ValidationExpression="http://([\w-]+\.)+[\w-]+(/[\w-
./?%&amp;=]*)?">*</asp:RegularExpressionValidator></td>
</tr>
<tr>
<td colSpan="2"><b>Mailer&nbsp;Image</b></td>
</tr>
<tr>
<td colSpan="2">
<asp:Image id="imgMainImage" runat="server"></asp:Image></td>
</tr>
<tr>
<td colSpan="2"><INPUT id="uploadMainImage" style="WIDTH: 600px"
type="file" size="80" runat="server">
</td>
</tr>
<tr>
<td colSpan="2">&nbsp;</td>
</tr>
<tr>
<td colSpan="2"><aspzone:eek:neclickbutton id="btnSubmit" runat="server"
Text="Submit"></aspzone:eek:neclickbutton>&nbsp;&nbsp;&nbsp;&nbsp;
<asp:button id="btnCancel" runat="server" Text="Cancel"
CausesValidation="False"></asp:button><asp:validationsummary
id="ValidationSummary1" runat="server" HeaderText="Errors!! Please correct
the following:"
ShowSummary="False"
ShowMessageBox="True"></asp:validationsummary>
</td>
</tr>
</table>
</form>

from code behind

if(Page.IsValid)
{
HttpFileCollection myFiles = Request.Files;
HttpPostedFile myFile = myFiles[0];

MailingListDB mlDB = new MailingListDB();
if((bool)ViewState["isAdd"] == true)
{
mlDB.AddNewMailer(txtSubject.Text.Trim(), txtBody.Text,
txtNavigateURL.Text.Trim(), ref myFile);
}
else
{
mlDB.UpdateExistingMailer((int)ViewState["MailerID"],
txtSubject.Text.Trim(), txtBody.Text, txtNavigateURL.Text.Trim(), ref
myFile);
}

if(ViewState["URLReferrer"] != null)
{
Response.Redirect(Convert.ToString(ViewState["URLReferrer"]));
}
else
{
Response.Redirect("~");
}
}

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
I have an application that uses FreeTextBox 2.0
(http://www.freetextbox.com). FreeTextBox is a rich text editor that
behaves
similarly to MS Word. The FreeTextBox control has a button to insert
images
(just as you would with MS Word) and it works beautifully. The problem is
that when you include an image with the rich text editor, the image path
is
the local path on the client. I have written a method that examines
the
text
for <img> tags, extracts the local path, and then replaces it with
what
the
virtual path will be after the file has been saved to the server.

I would like post the file to the server as I would with an HtmlInputFile
(PostedFile) control using the HttpPostedFile object, but it would appear
that this is not allowed. After doing some digging, it looks like my best
option would be to write a Web Service that accepts the image as a
byte
array and use the WebClient object to upload the file to the service.

It sounds like this would work but I don't really know how to approach
this.
I would rather just straight post the file to the
HttpPostedFileCollection
just like an HtmlInputFile control does, but that doesn't look like a
possible option. If anyone knows a good means to upload a file without
the
HtmlInputFile control, please let me know.

TIA,

Grant Harmeyer
 
S

sri_san

I am trying to use the code suggested by dave. I use the
freetextbox control. Not able to get it working when I insert an image
in the freetextbox control.
The "request.files" Collection is empty inspite of an image being
inserted into the freetextbox.
Any ideas?

Thanks,
Sam.

Hermit said:
what do you mean the htmlinput file is not allowed ?
i have used that object with freetextbox. have a look at this

<form id="Form1" method="post" runat="server">
<table cellSpacing="0" cellPadding="3" width="700" border="0">
<tr>
<td><uc1:moduletitle id="ModuleTitle1" runat="server"
DisplayText="Email Users"></uc1:moduletitle></td>
</tr>
<tr>
<td vAlign="top" align="left"><b>Mailer&nbsp;Subject</b></td>
<td><asp:requiredfieldvalidator id="RFVSubject" runat="server"
Display="Dynamic" ControlToValidate="txtSubject"
ErrorMessage="Subject
Required">* said:
</tr>
<tr>
<td colSpan="2"><asp:textbox id="txtSubject" runat="server"
MaxLength="100" Columns="50" Width="600px"></asp:textbox></td>
</tr>
<tr>
<td vAlign="top" align="left"><b>Mailer Body</b></td>
<td><asp:requiredfieldvalidator id="RFVBody" runat="server"
Display="Dynamic" ControlToValidate="txtBody" ErrorMessage="Item Text
Required">*</asp:requiredfieldvalidator></td>
</tr>
<tr>
<td colSpan="2"><FTB:FREETEXTBOX id="txtBody" runat="server"
Width="600px" BreakMode="LineBreak" DownLevelCols="50"

ToolbarLayout="paragraphmenu,fontsizesmenu,FontForeColorsMenu,FontBackColors
Menu|bold,italic,underline,Strikethrough, Superscript,
Subscript;JustifyLeft, JustifyRight, JustifyCenter,
JustifyFull;bulletedlist,numberedlist;CreateLink, Unlink; Cut, Copy, Paste,
Undo, Redo"></FTB:FREETEXTBOX></td>
</tr>
<tr>
<td colSpan="2"><b>Mailer&nbsp;Image Navigation URL</b></td>
</tr>
<tr>
<td>
<asp:TextBox id="txtNavigateURL" runat="server" Width="600px"
Columns="50" MaxLength="200"></asp:TextBox>
</td>
<td>
<asp:RegularExpressionValidator id="REVNavigateURL" runat="server"
ErrorMessage="Invalid URL for Image Navigation"
ControlToValidate="txtNavigateURL" Display="Dynamic"
ValidationExpression="http://([\w-]+\.)+[\w-]+(/[\w-
./?%&amp;=]*)?">*</asp:RegularExpressionValidator></td>
</tr>
<tr>
<td colSpan="2"><b>Mailer&nbsp;Image</b></td>
</tr>
<tr>
<td colSpan="2">
<asp:Image id="imgMainImage" runat="server"></asp:Image></td>
</tr>
<tr>
<td colSpan="2"><INPUT id="uploadMainImage" style="WIDTH: 600px"
type="file" size="80" runat="server">
</td>
</tr>
<tr>
<td colSpan="2">&nbsp;</td>
</tr>
<tr>
<td colSpan="2"><aspzone:eek:neclickbutton id="btnSubmit" runat="server"
Text="Submit"></aspzone:eek:neclickbutton>&nbsp;&nbsp;&nbsp;&nbsp;
<asp:button id="btnCancel" runat="server" Text="Cancel"
CausesValidation="False"></asp:button><asp:validationsummary
id="ValidationSummary1" runat="server" HeaderText="Errors!! Please correct
the following:"
ShowSummary="False"
ShowMessageBox="True"> said:
</td>
</tr>
</table>
</form>

from code behind

if(Page.IsValid)
{
HttpFileCollection myFiles = Request.Files;
HttpPostedFile myFile = myFiles[0];

MailingListDB mlDB = new MailingListDB();
if((bool)ViewState["isAdd"] == true)
{
mlDB.AddNewMailer(txtSubject.Text.Trim(), txtBody.Text,
txtNavigateURL.Text.Trim(), ref myFile);
}
else
{
mlDB.UpdateExistingMailer((int)ViewState["MailerID"],
txtSubject.Text.Trim(), txtBody.Text, txtNavigateURL.Text.Trim(), ref
myFile);
}

if(ViewState["URLReferrer"] != null)
{
Response.Redirect(Convert.ToString(ViewState["URLReferrer"]));
}
else
{
Response.Redirect("~");
}
}

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
Grant Harmeyer said:
I have an application that uses FreeTextBox 2.0
(http://www.freetextbox.com). FreeTextBox is a rich text editor
that
behaves
similarly to MS Word. The FreeTextBox control has a button to
insert
images
(just as you would with MS Word) and it works beautifully. The problem is
that when you include an image with the rich text editor, the image
path
is
the local path on the client. I have written a method that examines
the
text
for <img> tags, extracts the local path, and then replaces it with
what
the
virtual path will be after the file has been saved to the server.

I would like post the file to the server as I would with an HtmlInputFile
(PostedFile) control using the HttpPostedFile object, but it would appear
that this is not allowed. After doing some digging, it looks like my best
option would be to write a Web Service that accepts the image as a byte
array and use the WebClient object to upload the file to the service.

It sounds like this would work but I don't really know how to
approach
this.
I would rather just straight post the file to the HttpPostedFileCollection
just like an HtmlInputFile control does, but that doesn't look like a
possible option. If anyone knows a good means to upload a file without the
HtmlInputFile control, please let me know.

TIA,

Grant Harmeyer
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top