Showing posts with label application. Show all posts
Showing posts with label application. Show all posts

Thursday, March 29, 2012

Newbie: How to upload and save images using ASP.NET web forms (C#)

Hello -

I need to upload images in my web application using ASP.NET web forms
(written in C#). Since i have never done this before, i am unsure what is the
best method.

I assume there are two options:

1). Upload the images and save the files directory to the windows file
system. However, i assume this poses a security risk, as the file directory
will require write permissions.

2). Save the images (as objects?) in the SQL SERVER database.

Can anyone suggest the best way to do this? And, if possible, point me to
some sample code or artciles which explain how to do this.

Thanks!Charlie,

check out the following article:

http://www.codeproject.com/aspnet/fileupload.asp

I prefer to save files in the database but it depends on your needs.

If you need to save hundred thousands of files and decide that you want to
save them on your hard disk make sure to distribute them on different
directories. What you could do is that you assign a guid to each file and
create your directory structure accordingly.

Example:

You have five files with the following guids

0A59E8D6-0AE5-475B-8698-814C2C712029

F16CE1B1-56D0-42E6-9463-A58D553CC289

D90C27C7 -8BD9-4F47-8CFE-DE9D240AD136

370B6080-DF06-4DDE-BB5E-85264B8AE48B

861DC387-FDC7-4A4F-B0C3-9EA6734A562A

You could now create a directory like the following:

0A59E8D6\0AE5\475B\8698\814C2C712029

F16CE1B1\56D0\42E6\9463\A58D553CC289

D90C27C7 \8BD9\4F47\8CFE\DE9D240AD136

370B6080\DF06\4DDE\BB5E\85264B8AE48B

861DC387\FDC7\4A4F\B0C3\9EA6734A562A

HTHs

Daniel

"charliewest" <charliewest@.discussions.microsoft.com> schrieb im Newsbeitrag
news:E6DD7087-DC4F-4E78-9741-0EF7F76883B6@.microsoft.com...
> Hello -
> I need to upload images in my web application using ASP.NET web forms
> (written in C#). Since i have never done this before, i am unsure what is
> the
> best method.
> I assume there are two options:
> 1). Upload the images and save the files directory to the windows file
> system. However, i assume this poses a security risk, as the file
> directory
> will require write permissions.
> 2). Save the images (as objects?) in the SQL SERVER database.
> Can anyone suggest the best way to do this? And, if possible, point me to
> some sample code or artciles which explain how to do this.
> Thanks!

Monday, March 26, 2012

Newbie: parser error when using a Literal tag

Here goes.. I'm starting with a working application and am trying to make some modifications and things aren't going well.

I wanted to add a Literal tag to a page like in this article:
http://www.odetocode.com/Code/82.aspx

But I keep getting a parser error on my page:
Parser Error Message: The base class includes the field 'stylesheet', but its type (System.Web.UI.WebControls.Literal) is not compatible with the type of control (System.Web.UI.HtmlControls.HtmlGenericControl).

Here's my code:
-- from .aspx:


<LINK href="http://links.10026.com/?link=<asp:Literal id="stylesheet" runat="Server" />" type="text/css" rel="stylesheet">

-- from .aspx.vb:


Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Web
Imports System.Web.SessionState
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports System.Data.SqlClient
Imports System.Text
Imports System.Web.Security
Imports blueinc.BusinessLogicLayer
Imports blueinc.DataAccessLayer

Namespace myCompany.Web

Public Class _default
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub
Protected WithEvents dlEvents As System.Web.UI.WebControls.DataList
Protected WithEvents PlaceHolder As System.Web.UI.WebControls.PlaceHolder
Protected WithEvents lnkRegister As System.Web.UI.WebControls.LinkButton
Protected WithEvents lblUserLoggedOn As System.Web.UI.WebControls.Label
Protected WithEvents Separator As System.Web.UI.WebControls.Label
Protected WithEvents lnkLogOff As System.Web.UI.WebControls.LinkButton
Protected WithEvents dgClinics As System.Web.UI.WebControls.DataGrid

'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Dim EventsTable As BusinessLogicLayer.Events = New BusinessLogicLayer.Events
Public ClinicsTable As BusinessLogicLayer.Clinics = New BusinessLogicLayer.Clinics
Protected stylesheet As System.Web.UI.WebControls.Literal

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim uc As Control = Page.LoadControl("UserControls/Login.ascx")

If Not Request.IsAuthenticated Then
PlaceHolder.Controls.Add(uc)
lblUserLoggedOn.Visible = False
lnkLogOff.Visible = False
Else
Dim UserDetails As myCompany.BusinessLogicLayer.UserDetails
UserDetails = Session("UserDetails")

PlaceHolder.Controls.Remove(uc)
If Not IsNothing(UserDetails.UserName) Then
lblUserLoggedOn.Text = "Currently logged on as " & UserDetails.UserName
Else
lblUserLoggedOn.Text = "Authenticated but logged on as NO-ONE!"
End If
lblUserLoggedOn.Visible = True
lnkLogOff.Visible = True

End If

If Not IsPostBack Then
dlEvents.DataSource = EventsTable.GetList
dlEvents.DataBind()

dgClinics.DataSource = ClinicsTable.GetList
dgClinics.DataBind()

Dim OrgName As String

OrgName = Session("org")
If OrgName = "" Then
OrgName = Request("org")
End If
If OrgName = "" Then
OrgName = "foo"
End If

stylesheet.Text = OrgName & "/styles.css"
End If

End Sub

I would have snipped the code-behind, but I figured I'd end up snipping the offending line... I'd be happy to provide more info if required.

J<LINK href="http://links.10026.com/?link=" type="text/css" rel="stylesheet" id="stylesheet" runat="server" />

Protected WithEvents stylesheet As System.Web.UI.HtmlControls.HtmlGenericControl

' code:
stylesheet.Attributes.Add("href", "whatever value")


I think you're confusing the parser with nested tags. Try to make stylesheet a string instead of a literal and inject its value using <%= %>.
Even better, make the LINK tag runat=server (and declare it as a HtmlGenericControl in the code-behind) and set its properties using the Attributes collection.
Thank you both, its working now. I am making the link runat=server.

And when I took the literal out of the <link/> it also worked, so at least I know what the problem was!

Cheers,
J

newbie: preparing ASP.NET application for release

I have an ASP.NET application that I'm ready to upload onto a webserver
in a release format.

I just want to be sure of a few things first:

- I take it that I only need to upload the aspx files, the bin directory
files, stylesheets, global.asax and web.config onto the server?

(i.e. I don't need to upload the .vb source files and assemblynfo.vb,
etc?)

- Also, to prepare the application for release mode, do I just need to
set the <compilation> tag to debug="false" ?

Anything else I should know about?

Thanks,
Peter
--

"I hear ma train a comin'
... hear freedom comin"debug="false" compile the code i release mode (assuming you are using
VS.Net, that's just a dropdown that says DEBUG and RELEASE). you also need
ascx (user controls), asmx (web services), asax (global)

you can remove the vbproj and sln/suo files.

karl
--
MY ASP.Net tutorials
http://www.openmymind.net/

"Stimp" <ren@.spumco.com> wrote in message
news:slrncphetf.sp2.ren@.carbon.redbrick.dcu.ie...
> I have an ASP.NET application that I'm ready to upload onto a webserver
> in a release format.
> I just want to be sure of a few things first:
> - I take it that I only need to upload the aspx files, the bin directory
> files, stylesheets, global.asax and web.config onto the server?
> (i.e. I don't need to upload the .vb source files and assemblynfo.vb,
> etc?)
> - Also, to prepare the application for release mode, do I just need to
> set the <compilation> tag to debug="false" ?
> Anything else I should know about?
> Thanks,
> Peter
> --
> "I hear ma train a comin'
> ... hear freedom comin"
To depoly the project to the server you can use the copy project function in
the project menu (if you are using Visual Studio). Just check, copy "Only
files needed to run this application". You must have your ASP.NET project
selected in the solution explorer.

/Henke

"Stimp" <ren@.spumco.com> skrev i meddelandet
news:slrncphetf.sp2.ren@.carbon.redbrick.dcu.ie...
>I have an ASP.NET application that I'm ready to upload onto a webserver
> in a release format.
> I just want to be sure of a few things first:
> - I take it that I only need to upload the aspx files, the bin directory
> files, stylesheets, global.asax and web.config onto the server?
> (i.e. I don't need to upload the .vb source files and assemblynfo.vb,
> etc?)
> - Also, to prepare the application for release mode, do I just need to
> set the <compilation> tag to debug="false" ?
> Anything else I should know about?
> Thanks,
> Peter
> --
> "I hear ma train a comin'
> ... hear freedom comin"
... in addition to what guys suggested check out this:
http://msdn.microsoft.com/library/d.../CL_SecuAsp.asp
Pay attention to web.config settings, especially if your app is hosted on
shared server (hosting company or several apps on one server)

"Stimp" <ren@.spumco.com> wrote in message
news:slrncphetf.sp2.ren@.carbon.redbrick.dcu.ie...
>I have an ASP.NET application that I'm ready to upload onto a webserver
> in a release format.
> I just want to be sure of a few things first:
> - I take it that I only need to upload the aspx files, the bin directory
> files, stylesheets, global.asax and web.config onto the server?
> (i.e. I don't need to upload the .vb source files and assemblynfo.vb,
> etc?)
> - Also, to prepare the application for release mode, do I just need to
> set the <compilation> tag to debug="false" ?
> Anything else I should know about?
> Thanks,
> Peter
> --
> "I hear ma train a comin'
> ... hear freedom comin"

newbie: preparing ASP.NET application for release

I have an ASP.NET application that I'm ready to upload onto a webserver
in a release format.
I just want to be sure of a few things first:
- I take it that I only need to upload the aspx files, the bin directory
files, stylesheets, global.asax and web.config onto the server?
(i.e. I don't need to upload the .vb source files and assemblynfo.vb,
etc?)
- Also, to prepare the application for release mode, do I just need to
set the <compilation> tag to debug="false" ?
Anything else I should know about?
Thanks,
Peter
--
"I hear ma train a comin'
... hear freedom comin"debug="false" compile the code i release mode (assuming you are using
VS.Net, that's just a dropdown that says DEBUG and RELEASE). you also need
ascx (user controls), asmx (web services), asax (global)
you can remove the vbproj and sln/suo files.
karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Stimp" <ren@.spumco.com> wrote in message
news:slrncphetf.sp2.ren@.carbon.redbrick.dcu.ie...
> I have an ASP.NET application that I'm ready to upload onto a webserver
> in a release format.
> I just want to be sure of a few things first:
> - I take it that I only need to upload the aspx files, the bin directory
> files, stylesheets, global.asax and web.config onto the server?
> (i.e. I don't need to upload the .vb source files and assemblynfo.vb,
> etc?)
> - Also, to prepare the application for release mode, do I just need to
> set the <compilation> tag to debug="false" ?
> Anything else I should know about?
> Thanks,
> Peter
> --
> "I hear ma train a comin'
> ... hear freedom comin"
To depoly the project to the server you can use the copy project function in
the project menu (if you are using Visual Studio). Just check, copy "Only
files needed to run this application". You must have your ASP.NET project
selected in the solution explorer.
/Henke
"Stimp" <ren@.spumco.com> skrev i meddelandet
news:slrncphetf.sp2.ren@.carbon.redbrick.dcu.ie...
>I have an ASP.NET application that I'm ready to upload onto a webserver
> in a release format.
> I just want to be sure of a few things first:
> - I take it that I only need to upload the aspx files, the bin directory
> files, stylesheets, global.asax and web.config onto the server?
> (i.e. I don't need to upload the .vb source files and assemblynfo.vb,
> etc?)
> - Also, to prepare the application for release mode, do I just need to
> set the <compilation> tag to debug="false" ?
> Anything else I should know about?
> Thanks,
> Peter
> --
> "I hear ma train a comin'
> ... hear freedom comin"
... in addition to what guys suggested check out this:
http://msdn.microsoft.com/library/d.../>
SecuAsp.asp
Pay attention to web.config settings, especially if your app is hosted on
shared server (hosting company or several apps on one server)
"Stimp" <ren@.spumco.com> wrote in message
news:slrncphetf.sp2.ren@.carbon.redbrick.dcu.ie...
>I have an ASP.NET application that I'm ready to upload onto a webserver
> in a release format.
> I just want to be sure of a few things first:
> - I take it that I only need to upload the aspx files, the bin directory
> files, stylesheets, global.asax and web.config onto the server?
> (i.e. I don't need to upload the .vb source files and assemblynfo.vb,
> etc?)
> - Also, to prepare the application for release mode, do I just need to
> set the <compilation> tag to debug="false" ?
> Anything else I should know about?
> Thanks,
> Peter
> --
> "I hear ma train a comin'
> ... hear freedom comin"

Saturday, March 24, 2012

newbie: running asp.bnet application

Hi,

I am trying to run an ASP.net application. What files do I need to keep in inteup and what files can I put anywhere else on my HDisk.??

Thanks,

Hello Bilalso,

I am not really sure what you mean but maybe this will help you out.

The files needed to run an ASP.NET application are all.aspx pages and the completebin folder. The codebehind files (.aspx.cs) are not necessary to run the application when it is compiled all codebehind code is stored in a.dll file which is stored in thebin folder. When you are using usercontrols you should also store the.ascx files and of course any third parties components should be included (usually in thebin folder).

You can store you're website anywhere on your hardrive as long as you configure IIS correctly. To do this create a virtual website under the Default website using the following steps:

- Open IIS
- Select the Default website and press the right mouse button
- Goto New -> Virtual website
- Submit an Alias for the Virual directory (can be anything you want)
- Now select the directory where your website is located on your harddrive
- Leave the access permissions as they are (unless you have special wishes)
- Hit the Finish button and you are ready

A hope this answers your question.

Cheers, Maurits


Hello:

You need to create a new website with either Visual Studio.NET, WebMatrix, Visual Web Express. They will create the website for you, in the wwwroot folder of the inetpub.

Have you installed .NET om your machine?

Regards

newbie: session & URL

hey

asp.net 2.0

I prefer to send parameter between pages in a web application using GET (ex:
Default.aspx?id=1) so that the URL becomes unique so the user can add the
page to favorites...

Because I now uses a sitemap I can no longer use GET. I have to put it in a
session object... Is there a solution to make it possible to add pages to
favorite even if the parameter to the page is set in a session object?

Any suggestion?

Jeffhi jeff,
here is the code to convert session object to QueryString object (simple
object only):

private void Page_Load(object sender, EventArgs e)
{
if(!Page.IsPostBack)
{
ConvertSessionToQueryString("ABCSystem_INT_ID","id");
}
//use Request["id"] to do something.

}

private void ConvertSessionToQueryString(string sessionname, string
querystringname)
{
if (Session[sessionname]!=null&&Request[querystringname]==null)
{
string id = Session["SystemName_ObjectName_ID"].ToString();
Response.Redirect("Default.aspx?id="+id,true);
}
}

"Jeff" <it_consultant1@.hotmail.com.NOSPAM>
:e2HZgOcsGHA.1632@.TK2MSFTNGP06.phx.gbl...

Quote:

Originally Posted by

hey
>
asp.net 2.0
>
I prefer to send parameter between pages in a web application using GET
(ex: Default.aspx?id=1) so that the URL becomes unique so the user can add
the page to favorites...
>
Because I now uses a sitemap I can no longer use GET. I have to put it in
a session object... Is there a solution to make it possible to add pages
to favorite even if the parameter to the page is set in a session object?
>
Any suggestion?
>
Jeff
>

Newbie: Trouble w/ ViewState

I would greatly appreciate any assistance any one could give me. I have an
ASP.NET application that contains two frames and several popup windows for
editing information. One of the frames contains a treeview with a long list
of clients with several node underneath each client for different tasks. If
I change some information in the other frame or one of the popup windows tha
t
directly reflects on the information in my treeview, how can I reload or
postback the page my treeview is on and still maintain the view state of the
control? I know the view state is not maintained unless the postback comes
from that page, but is there any way I can capture the treeview's view state
and use it from another page? Is there something similar to view state I ca
n
use in its place?
Chrisdsmith66,
If you have a problem with the viewstate you can always save it away in the
session.
Arne.
"clsmith66" wrote:

> I would greatly appreciate any assistance any one could give me. I have a
n
> ASP.NET application that contains two frames and several popup windows for
> editing information. One of the frames contains a treeview with a long li
st
> of clients with several node underneath each client for different tasks.
If
> I change some information in the other frame or one of the popup windows t
hat
> directly reflects on the information in my treeview, how can I reload or
> postback the page my treeview is on and still maintain the view state of t
he
> control? I know the view state is not maintained unless the postback come
s
> from that page, but is there any way I can capture the treeview's view sta
te
> and use it from another page? Is there something similar to view state I
can
> use in its place?
> Chris

Newbie: Trouble w/ ViewState

I would greatly appreciate any assistance any one could give me. I have an
ASP.NET application that contains two frames and several popup windows for
editing information. One of the frames contains a treeview with a long list
of clients with several node underneath each client for different tasks. If
I change some information in the other frame or one of the popup windows that
directly reflects on the information in my treeview, how can I reload or
postback the page my treeview is on and still maintain the view state of the
control? I know the view state is not maintained unless the postback comes
from that page, but is there any way I can capture the treeview's view state
and use it from another page? Is there something similar to view state I can
use in its place?

Chrisdsmith66,
If you have a problem with the viewstate you can always save it away in the
session.
Arne.

"clsmith66" wrote:

> I would greatly appreciate any assistance any one could give me. I have an
> ASP.NET application that contains two frames and several popup windows for
> editing information. One of the frames contains a treeview with a long list
> of clients with several node underneath each client for different tasks. If
> I change some information in the other frame or one of the popup windows that
> directly reflects on the information in my treeview, how can I reload or
> postback the page my treeview is on and still maintain the view state of the
> control? I know the view state is not maintained unless the postback comes
> from that page, but is there any way I can capture the treeview's view state
> and use it from another page? Is there something similar to view state I can
> use in its place?
> Chris

Newbie:please help me 'display' this on a simple .aspx page

I understand that store procedures are the recommended way to handle SQL
queries from an ASP application. However I am working on a small academic
assignment and I just need to get this over with. I created the store
procedure but now the teacher didn't accept that, as he is concerned he
would need to install the store procedure in Query Analyzer from his end.
Can you please clarify how I would be to do the following using a Select
Statement (VB.NET, ASP.NET 2.0):
Dim myNextPage
myNextPage = "ConfirmInput.aspx" 'On this page I put a label.Text there.
Dim myString
myString = "SELECT Employee From Pubs " _
& "WHERE job_id = " & TxtBox1.Text And
& "WHERE employee_name = " & TxtBox2.Text And
& "WHERE hire_date = " & TxtBox3.Text
'Now I want to:
If (TxtBox1.Text = job_id ) And (employee_name = TxtBox2.Text) And
(hire_date = TxtBox3.Text) Then
Response.Redirect("myNextPage")
'Then on Next page I would like to display label.Text = "Your
information matched and I can go ahead to reset your password in AD..."
'However doing:
label.Text = "Your info matched and I can go ahead and reset your
password in AD..." ' This wouldn't work. Where do I need to put this
Label.Text ="..." ?
Else
Response.Redirect("myNextPage")
'Display on next page Label.Text = "The phrase(s) you typed didn't
match. Please click back button and resubmit info."
'If possible, I would like to display all phrases that did not match
in 'myNextPage', so that user would know which ones he didn't answer
correctly.
End If
End SubIn that case u may choose to write all logic of stored procedure in asp.net
itsself.
-jignesh
www.dotnetjini.com
"Marlon Brown" <marlon_brownj@.hotmail.com> wrote in message
news:e7u1sygJFHA.2772@.TK2MSFTNGP14.phx.gbl...
> I understand that store procedures are the recommended way to handle SQL
> queries from an ASP application. However I am working on a small academic
> assignment and I just need to get this over with. I created the store
> procedure but now the teacher didn't accept that, as he is concerned he
> would need to install the store procedure in Query Analyzer from his end.
> Can you please clarify how I would be to do the following using a Select
> Statement (VB.NET, ASP.NET 2.0):
>
> Dim myNextPage
> myNextPage = "ConfirmInput.aspx" 'On this page I put a label.Text there.
> Dim myString
> myString = "SELECT Employee From Pubs " _
> & "WHERE job_id = " & TxtBox1.Text And
> & "WHERE employee_name = " & TxtBox2.Text And
> & "WHERE hire_date = " & TxtBox3.Text
> 'Now I want to:
> If (TxtBox1.Text = job_id ) And (employee_name = TxtBox2.Text) And
> (hire_date = TxtBox3.Text) Then
> Response.Redirect("myNextPage")
> 'Then on Next page I would like to display label.Text = "Your
> information matched and I can go ahead to reset your password in AD..."
> 'However doing:
> label.Text = "Your info matched and I can go ahead and reset your
> password in AD..." ' This wouldn't work. Where do I need to put this
> Label.Text ="..." ?
> Else
> Response.Redirect("myNextPage")
> 'Display on next page Label.Text = "The phrase(s) you typed didn't
> match. Please click back button and resubmit info."
> 'If possible, I would like to display all phrases that did not match
> in 'myNextPage', so that user would know which ones he didn't answer
> correctly.
> End If
> End Sub
>
Ok, if you can't show me the SQL part OK, but could you help me with on how
to display whatever variable I capture from the SQL query on .ASP.NET ?
I tried to use Response.Write(TextBox1.Text) but that didn't returned
satisfactory results. I understand I shouldn't use Response.Write and
therefore I attempted to create a Label1.Text to display whatever
information I got from SQL. The problem is that I do Label1.Text =
InfoFromSQL and that doesn't work either. It returns nothing on the
Label1.Text.
'Then on Next page I would like to display label.Text = "Your
'information matched and I can go ahead to reset your password in AD..."
' 'However doing:
' label.Text = "Your info matched and I can go ahead and reset your
' password in AD..." ' This wouldn't work. Where do I need to put this
' Label.Text ="..." ?
I am trying to
"Jignesh Desai" <jignesh_desai@.hotmail.com> wrote in message
news:O8z%238QhJFHA.2356@.TK2MSFTNGP14.phx.gbl...
> In that case u may choose to write all logic of stored procedure in
> asp.net
> itsself.
> -jignesh
> www.dotnetjini.com
> "Marlon Brown" <marlon_brownj@.hotmail.com> wrote in message
> news:e7u1sygJFHA.2772@.TK2MSFTNGP14.phx.gbl...
>
Labels do not produce actual HTML control on the client-side so have no way
to postback to the server. I believe you can store you texts in Session
variable.
Session["yourmsg"] = "Your info matched and I can go ahead and reset your
password in AD..."
Then in the other page:
label.Text = CStr(Session["yourmsg"])
You may use Session variable to store anything, including ArrayList and
access it on other pages in the same session. Just rememeber to CType it
back when you retrieve it.
"Marlon Brown" <marlon_brownj@.hotmail.com> bl
news:e7u1sygJFHA.2772@.TK2MSFTNGP14.phx.gbl g...
> I understand that store procedures are the recommended way to handle SQL
> queries from an ASP application. However I am working on a small academic
> assignment and I just need to get this over with. I created the store
> procedure but now the teacher didn't accept that, as he is concerned he
> would need to install the store procedure in Query Analyzer from his end.
> Can you please clarify how I would be to do the following using a Select
> Statement (VB.NET, ASP.NET 2.0):
>
> Dim myNextPage
> myNextPage = "ConfirmInput.aspx" 'On this page I put a label.Text there.
> Dim myString
> myString = "SELECT Employee From Pubs " _
> & "WHERE job_id = " & TxtBox1.Text And
> & "WHERE employee_name = " & TxtBox2.Text And
> & "WHERE hire_date = " & TxtBox3.Text
> 'Now I want to:
> If (TxtBox1.Text = job_id ) And (employee_name = TxtBox2.Text) And
> (hire_date = TxtBox3.Text) Then
> Response.Redirect("myNextPage")
> 'Then on Next page I would like to display label.Text = "Your
> information matched and I can go ahead to reset your password in AD..."
> 'However doing:
> label.Text = "Your info matched and I can go ahead and reset your
> password in AD..." ' This wouldn't work. Where do I need to put this
> Label.Text ="..." ?
> Else
> Response.Redirect("myNextPage")
> 'Display on next page Label.Text = "The phrase(s) you typed didn't
> match. Please click back button and resubmit info."
> 'If possible, I would like to display all phrases that did not match
> in 'myNextPage', so that user would know which ones he didn't answer
> correctly.
> End If
> End Sub
>

Newbie:please help me display this on a simple .aspx page

I understand that store procedures are the recommended way to handle SQL
queries from an ASP application. However I am working on a small academic
assignment and I just need to get this over with. I created the store
procedure but now the teacher didn't accept that, as he is concerned he
would need to install the store procedure in Query Analyzer from his end.
Can you please clarify how I would be to do the following using a Select
Statement (VB.NET, ASP.NET 2.0):

Dim myNextPage
myNextPage = "ConfirmInput.aspx" 'On this page I put a label.Text there.

Dim myString
myString = "SELECT Employee From Pubs " _
& "WHERE job_id = " & TxtBox1.Text And
& "WHERE employee_name = " & TxtBox2.Text And
& "WHERE hire_date = " & TxtBox3.Text

'Now I want to:
If (TxtBox1.Text = job_id ) And (employee_name = TxtBox2.Text) And
(hire_date = TxtBox3.Text) Then
Response.Redirect("myNextPage")
'Then on Next page I would like to display label.Text = "Your
information matched and I can go ahead to reset your password in AD..."
'However doing:
label.Text = "Your info matched and I can go ahead and reset your
password in AD..." ' This wouldn't work. Where do I need to put this
Label.Text ="..." ?

Else
Response.Redirect("myNextPage")
'Display on next page Label.Text = "The phrase(s) you typed didn't
match. Please click back button and resubmit info."
'If possible, I would like to display all phrases that did not match
in 'myNextPage', so that user would know which ones he didn't answer
correctly.

End If

End SubIn that case u may choose to write all logic of stored procedure in asp.net
itsself.

-jignesh
www.dotnetjini.com

"Marlon Brown" <marlon_brownj@.hotmail.com> wrote in message
news:e7u1sygJFHA.2772@.TK2MSFTNGP14.phx.gbl...
> I understand that store procedures are the recommended way to handle SQL
> queries from an ASP application. However I am working on a small academic
> assignment and I just need to get this over with. I created the store
> procedure but now the teacher didn't accept that, as he is concerned he
> would need to install the store procedure in Query Analyzer from his end.
> Can you please clarify how I would be to do the following using a Select
> Statement (VB.NET, ASP.NET 2.0):
>
> Dim myNextPage
> myNextPage = "ConfirmInput.aspx" 'On this page I put a label.Text there.
> Dim myString
> myString = "SELECT Employee From Pubs " _
> & "WHERE job_id = " & TxtBox1.Text And
> & "WHERE employee_name = " & TxtBox2.Text And
> & "WHERE hire_date = " & TxtBox3.Text
> 'Now I want to:
> If (TxtBox1.Text = job_id ) And (employee_name = TxtBox2.Text) And
> (hire_date = TxtBox3.Text) Then
> Response.Redirect("myNextPage")
> 'Then on Next page I would like to display label.Text = "Your
> information matched and I can go ahead to reset your password in AD..."
> 'However doing:
> label.Text = "Your info matched and I can go ahead and reset your
> password in AD..." ' This wouldn't work. Where do I need to put this
> Label.Text ="..." ?
> Else
> Response.Redirect("myNextPage")
> 'Display on next page Label.Text = "The phrase(s) you typed didn't
> match. Please click back button and resubmit info."
> 'If possible, I would like to display all phrases that did not match
> in 'myNextPage', so that user would know which ones he didn't answer
> correctly.
> End If
> End Sub
Ok, if you can't show me the SQL part OK, but could you help me with on how
to display whatever variable I capture from the SQL query on .ASP.NET ?
I tried to use Response.Write(TextBox1.Text) but that didn't returned
satisfactory results. I understand I shouldn't use Response.Write and
therefore I attempted to create a Label1.Text to display whatever
information I got from SQL. The problem is that I do Label1.Text =
InfoFromSQL and that doesn't work either. It returns nothing on the
Label1.Text.

'Then on Next page I would like to display label.Text = "Your
'information matched and I can go ahead to reset your password in AD..."
' 'However doing:
' label.Text = "Your info matched and I can go ahead and reset your
' password in AD..." ' This wouldn't work. Where do I need to put this
' Label.Text ="..." ?

I am trying to
"Jignesh Desai" <jignesh_desai@.hotmail.com> wrote in message
news:O8z%238QhJFHA.2356@.TK2MSFTNGP14.phx.gbl...
> In that case u may choose to write all logic of stored procedure in
> asp.net
> itsself.
> -jignesh
> www.dotnetjini.com
> "Marlon Brown" <marlon_brownj@.hotmail.com> wrote in message
> news:e7u1sygJFHA.2772@.TK2MSFTNGP14.phx.gbl...
>> I understand that store procedures are the recommended way to handle SQL
>> queries from an ASP application. However I am working on a small academic
>> assignment and I just need to get this over with. I created the store
>> procedure but now the teacher didn't accept that, as he is concerned he
>> would need to install the store procedure in Query Analyzer from his end.
>> Can you please clarify how I would be to do the following using a Select
>> Statement (VB.NET, ASP.NET 2.0):
>>
>>
>>
>> Dim myNextPage
>> myNextPage = "ConfirmInput.aspx" 'On this page I put a label.Text there.
>>
>> Dim myString
>> myString = "SELECT Employee From Pubs " _
>> & "WHERE job_id = " & TxtBox1.Text And
>> & "WHERE employee_name = " & TxtBox2.Text
>> And
>> & "WHERE hire_date = " & TxtBox3.Text
>>
>> 'Now I want to:
>> If (TxtBox1.Text = job_id ) And (employee_name = TxtBox2.Text) And
>> (hire_date = TxtBox3.Text) Then
>> Response.Redirect("myNextPage")
>> 'Then on Next page I would like to display label.Text = "Your
>> information matched and I can go ahead to reset your password in AD..."
>> 'However doing:
>> label.Text = "Your info matched and I can go ahead and reset your
>> password in AD..." ' This wouldn't work. Where do I need to put this
>> Label.Text ="..." ?
>>
>> Else
>> Response.Redirect("myNextPage")
>> 'Display on next page Label.Text = "The phrase(s) you typed didn't
>> match. Please click back button and resubmit info."
>> 'If possible, I would like to display all phrases that did not
>> match
>> in 'myNextPage', so that user would know which ones he didn't answer
>> correctly.
>>
>> End If
>>
>> End Sub
>>
>>
Labels do not produce actual HTML control on the client-side so have no way
to postback to the server. I believe you can store you texts in Session
variable.

Session["yourmsg"] = "Your info matched and I can go ahead and reset your
password in AD..."

Then in the other page:
label.Text = CStr(Session["yourmsg"])

You may use Session variable to store anything, including ArrayList and
access it on other pages in the same session. Just rememeber to CType it
back when you retrieve it.

"Marlon Brown" <marlon_brownj@.hotmail.com> bl
news:e7u1sygJFHA.2772@.TK2MSFTNGP14.phx.gbl g...
> I understand that store procedures are the recommended way to handle SQL
> queries from an ASP application. However I am working on a small academic
> assignment and I just need to get this over with. I created the store
> procedure but now the teacher didn't accept that, as he is concerned he
> would need to install the store procedure in Query Analyzer from his end.
> Can you please clarify how I would be to do the following using a Select
> Statement (VB.NET, ASP.NET 2.0):
>
> Dim myNextPage
> myNextPage = "ConfirmInput.aspx" 'On this page I put a label.Text there.
> Dim myString
> myString = "SELECT Employee From Pubs " _
> & "WHERE job_id = " & TxtBox1.Text And
> & "WHERE employee_name = " & TxtBox2.Text And
> & "WHERE hire_date = " & TxtBox3.Text
> 'Now I want to:
> If (TxtBox1.Text = job_id ) And (employee_name = TxtBox2.Text) And
> (hire_date = TxtBox3.Text) Then
> Response.Redirect("myNextPage")
> 'Then on Next page I would like to display label.Text = "Your
> information matched and I can go ahead to reset your password in AD..."
> 'However doing:
> label.Text = "Your info matched and I can go ahead and reset your
> password in AD..." ' This wouldn't work. Where do I need to put this
> Label.Text ="..." ?
> Else
> Response.Redirect("myNextPage")
> 'Display on next page Label.Text = "The phrase(s) you typed didn't
> match. Please click back button and resubmit info."
> 'If possible, I would like to display all phrases that did not match
> in 'myNextPage', so that user would know which ones he didn't answer
> correctly.
> End If
> End Sub

Thursday, March 22, 2012

Newbie:sending German characters on TCP link

Hi,

I've a .NET application that sends XML string as bytes on a TCP
connection. It had used ASCII encoding so far and everything was fine. Now
on a German OS, German characters were sent as question mark in the received
string. I guess that's because ASCII encoding was used and unicode encoding
should be used instead. But then would byte ordering(little endian ir big
endian) be a problem because the received TCP stream could be consumed by
both a Java and .NET clients ? What could be done to ensure that the
received unicode encoded XML stream be decoded by both .NET and Java clients
? And, which encoding .NET class be used utf8, utf32,.. ? Is there a sample
anywhere ?

Thanks in advance and regards

NavinOn Feb 27, 7:44 pm, "Navin Mishra" <navin.mis...@.siemens.comwrote:

Quote:

Originally Posted by

Hi,
>
I've a .NET application that sends XML string as bytes on a TCP
connection. It had used ASCII encoding so far and everything was fine. Now
on a German OS, German characters were sent as question mark in the received
string. I guess that's because ASCII encoding was used and unicode encoding
should be used instead. But then would byte ordering(little endian ir big
endian) be a problem because the received TCP stream could be consumed by
both a Java and .NET clients ? What could be done to ensure that the
received unicode encoded XML stream be decoded by both .NET and Java clients
? And, which encoding .NET class be used utf8, utf32,.. ? Is there a sample
anywhere ?
>


This group is for ASP.NET

Regarding your problem

First of all, ensure that the xml is encoded

sXML = "<?xml version=""1.0"" encoding=""windows-1252""?

Quote:

Originally Posted by

>.........."


then set this encoding to the method which send the data.

For example

myWriter = New System.IO.StreamWriter(xmlRequest.GetRequestStream (),
Encoding.GetEncoding(1252))
myWriter.Write(sXML)

I used German code page 1252 here, but you can consider to use utf-8...
Thus wrote Navin,

Quote:

Originally Posted by

Hi,
>
I've a .NET application that sends XML string as bytes on a TCP
connection. It had used ASCII encoding so far and everything was fine.
Now on a German OS, German characters were sent as question mark in
the received string. I guess that's because ASCII encoding was used
and unicode encoding should be used instead.


Absolutely. If not Unicode, then at least some 8 bit encoding like ISO Latin
1.

Quote:

Originally Posted by

But then would byte
ordering(little endian ir big endian) be a problem because the
received TCP stream could be consumed by both a Java and .NET clients
?


No. All UTF-16/32 variants include byte order marks that allow the receiver
to pick up the appropriate byte order, and UTF-8 is the same for both Big
Endian and Little Endian systems.

Quote:

Originally Posted by

What could be done to ensure that the received unicode encoded XML
stream be decoded by both .NET and Java clients ? And, which encoding
.NET class be used utf8, utf32,.. ? Is there a sample anywhere ?


If your XML contains mostly Latin characters, use UTF-8. That'll require
the least bandwidth. You can write an XML document to any stream using either
an XmlWriter or XmlDocument.Save().

Cheers,
--
Joerg Jooss
news-reply@.joergjooss.de

Newbie:sending German characters on TCP link

Hi,
I've a .NET application that sends XML string as bytes on a TCP
connection. It had used ASCII encoding so far and everything was fine. Now
on a German OS, German characters were sent as question mark in the received
string. I guess that's because ASCII encoding was used and unicode encoding
should be used instead. But then would byte ordering(little endian ir big
endian) be a problem because the received TCP stream could be consumed by
both a Java and .NET clients ? What could be done to ensure that the
received unicode encoded XML stream be decoded by both .NET and Java clients
? And, which encoding .NET class be used utf8, utf32,.. ? Is there a sample
anywhere ?
Thanks in advance and regards
NavinOn Feb 27, 7:44 pm, "Navin Mishra" <navin.mis...@.siemens.com> wrote:
> Hi,
> I've a .NET application that sends XML string as bytes on a TCP
> connection. It had used ASCII encoding so far and everything was fine. Now
> on a German OS, German characters were sent as question mark in the receiv
ed
> string. I guess that's because ASCII encoding was used and unicode encodin
g
> should be used instead. But then would byte ordering(little endian ir big
> endian) be a problem because the received TCP stream could be consumed by
> both a Java and .NET clients ? What could be done to ensure that the
> received unicode encoded XML stream be decoded by both .NET and Java clien
ts
> ? And, which encoding .NET class be used utf8, utf32,.. ? Is there a sampl
e
> anywhere ?
>
This group is for ASP.NET
Regarding your problem
First of all, ensure that the xml is encoded
sXML = "<?xml version=""1.0"" encoding=""windows-1252""?
>.........."
then set this encoding to the method which send the data.
For example
myWriter = New System.IO.StreamWriter(xmlRequest.GetRequestStream(),
Encoding.GetEncoding(1252))
myWriter.Write(sXML)
I used German code page 1252 here, but you can consider to use utf-8...
Thus wrote Navin,

> Hi,
> I've a .NET application that sends XML string as bytes on a TCP
> connection. It had used ASCII encoding so far and everything was fine.
> Now on a German OS, German characters were sent as question mark in
> the received string. I guess that's because ASCII encoding was used
> and unicode encoding should be used instead.
Absolutely. If not Unicode, then at least some 8 bit encoding like ISO Latin
1.

> But then would byte
> ordering(little endian ir big endian) be a problem because the
> received TCP stream could be consumed by both a Java and .NET clients
> ?
No. All UTF-16/32 variants include byte order marks that allow the receiver
to pick up the appropriate byte order, and UTF-8 is the same for both Big
Endian and Little Endian systems.

> What could be done to ensure that the received unicode encoded XML
> stream be decoded by both .NET and Java clients ? And, which encoding
> .NET class be used utf8, utf32,.. ? Is there a sample anywhere ?
If your XML contains mostly Latin characters, use UTF-8. That'll require
the least bandwidth. You can write an XML document to any stream using eithe
r
an XmlWriter or XmlDocument.Save().
Cheers,
--
Joerg Jooss
news-reply@.joergjooss.de

Friday, March 16, 2012

News Feed

hi,
pls i need help. am building a web application that dynamically retrieves news from different sources e.g stock exchange news, headlines news etc and displays the title, description and a link to the site.I bet you would get a lot more help if you actually asked a question :)
Hi,

from what I can make out of your post you're looking forScreen Scrapes in ASP.NET.

Grz, Kris.

Newsletter application

Hey,

I've created a really usefull newsletter application, but it's single user. This means I've created a physical mailbox by hand.
Someone pointed out to me that in order to let user create and send out their own newsletters they need a physical mailbox
aswell. Is this true?

What if I get a 10.000 users, how can I manage so many mailnoxes on a single machine and how to avoid my mailserver getting
marked as a spamserver (blacklisted)?

Should I work with so called smarthosts?

Hope someone has experience with newsletter applications + mailservers.

Cheers!

Hi,

You might have heard of DotNetNuke an open source portal software which comes with full source code.
DNN has a feature that allows administrators of the portals to send out HTML newsletters to a selection of roles or individual users.
The news letters sending has an Asynchronous and Synchronous mode of sending emails.

Download the source code from herehttp://www.dotnetnuke.com/tabid/125/default.aspx and check out the source code you might some good ideas on how to solve your problems.

Goodluck

Newsletter application

I need help on creating newsletter application which creates database with name and emailaddress and sends out newsletter every month using asp.net 2.0. I need to know how to create and send news letter?

What part are you stuck on? To tell you how to program a newsletter application would take a small book. Have you looked at existing products?

Jeff


So far I only know to create front end so that user can enter their email address and subscribe or unsubscribe.

I want to know how to create Newsletter (with html, dhtml, javascript...etc very dynamic newsletter) and email every month. (this part I dont understand). There are third party products available but them might be using asp.net or some other program, I want to try myself.

can you please guide me from here?


I would suggest using the FreeTextBox control (rich, HTML type textbox), for entering your newsletter information, which is available here:
http://freetextbox.com

Then, checkout this tutorial atASPNet101.com:
http://aspnet101.com/aspnet101/tutorials.aspx?id=41


I am able to send multiple email with plain text but when I try to attach colors, pictures, formatting etc it's not working form me.

is it possible to create newsletter in Frontpage or Flash etc and attach as part of email (not as attachment). or some other better way.

I looked into free text control but I still need to figure out how to make that work.


What part isnt working, and have you made sure and used the isbodyhtml = true in your code creating the message, that is an important step.

Colors, fonts, solid tables ect are easy if you can get your email to send in html. Images are a bit different, you can either hard link them to an external server, like <img src=http://myserver.com/image.jpg /> or you need to embed the image into the email itself, much like outlook or outlook express does it Fire up OE and look at the source to a message that has an embeded picture (not an attached one).


how can I embed a HTML page created in Frontpage , flash etc as newsletter to multiple addresses?


Save to a file and attach it or copy the rendered HTML and paste it into the message. Neither are a good way to send HTML email though.

Jeff


what other options I have to make it work better? I dont want to buy any third party product. An good example will help me understand better.

Define better...your asking very general questions. Do you need help creating an html email through code? Do you have an error your getting when you try to send an email through your server using asp.net?

Do you not know how to write HTML, so that you can paste it into a mail message?

Try this...This just gets the body of the message from a text / html file. I copied an IBM newsletter that I had gotten in an email, to a textfile in my solution called...textfile.txt...original huh.

Imports

System.Net.Mail

Imports

System.IOProtectedSub DoEmail()Dim msgAsString = ReadTextFile()Dim myClientAsNew SmtpClientDim myMessageAsNew MailMessageTry

myMessage.From =

New MailAddress("email@.email.com")

myMessage.To.Add(

"to@.email.com")

myMessage.Subject =

"My Subject"

myMessage.IsBodyHtml =

True

myMessage.Body = msg

myClient.Host =

"mailserver"

myClient.Port = 25

myClient.Send(myMessage)

Catch exAs Exception

Response.Write(ex.ToString)

EndTry

EndSubProtectedFunction ReadTextFile()AsStringDim myFileAsString = Server.MapPath("textfile.txt")Dim SRAs StreamReaderTry

SR = File.OpenText(myFile)

ReadTextFile = SR.ReadToEnd()

Catch exAs Exception

ReadTextFile = ex.ToString

Finally

SR.Close()

EndTryEndFunction


I got almost 90% working. Some how my CSS stlyesheet are not working when send via email.

Include your styles in the HTML, not as separate files.

Jeff


They are included inside html.

Internall user dont see CSS effect in theri outlook but I tried to send it to my yahoo mail and it worked fine. how can i make that work for outlook users?


is your CSS an external link?
remember that viewing HTML mail is an option that can be turned off ( I have it turned off in my outlook express)
it would probably help to see some code...

It would also help to see the rendered source of a message from your outlook, so we can determine if it's not getting there the way it should.

From inside outlook, open the message (not in your preview pane) and then right click somewhere inside the message body and choose "View Source"

Copy and paste a short version of the mail message your trying to send.