Showing posts with label ive. Show all posts
Showing posts with label ive. Show all posts

Thursday, March 29, 2012

Please forgive my ignorance, but I've never worked with ASP.NET before

We're trying out Visual Studio 2005 Professional from the Microsoft
website before paying for the unlocked version.
What I am trying to do is build on the simple ASP.NET web service.
HelloWorld is great, and I kind of see how it works.
What I can not comprehend is how to build an actual ASP that will take
an XML input, parse it, send the data to an external website as an
HTTP request, then parse the response, and send it back to the client
(actually another server).
Let's say you have a web method that takes parameters p1, p2, and p3.
It would then send an HTTP request (the external service can't take
XML for some weird reason) with parameters a1, a2, a3, a4 and a5.
When the response comes back, it would get parameters b1, b2 and b3
and return to the client the response with parameters c1, c2, c3 and
c4.
I noticed the web method can take parameters as if it were a VB
procedure, but this is going to be an XML formatted document coming
from a server that is in Java code (can't modify that code, even if I
knew a lick of Java).
Can someone help me? I keep searching the help, but I get a ton of
articles that just happen to have the words in them, rather than
something specific.
Would greatly appreciate it. Also, unless I have to, I would like to
avoid XSLT in order to be able to do this in the Standard Edition.On Jul 12, 8:57 pm, Brent White <bwh...@.badgersportswear.com> wrote:
> We're trying out Visual Studio 2005 Professional from the Microsoft
> website before paying for the unlocked version.
> What I am trying to do is build on the simple ASP.NET web service.
> HelloWorld is great, and I kind of see how it works.
> What I can not comprehend is how to build an actual ASP that will take
> an XML input, parse it, send the data to an external website as an
> HTTP request, then parse the response, and send it back to the client
> (actually another server).
> Let's say you have a web method that takes parameters p1, p2, and p3.
> It would then send an HTTP request (the external service can't take
> XML for some weird reason) with parameters a1, a2, a3, a4 and a5.
> When the response comes back, it would get parameters b1, b2 and b3
> and return to the client the response with parameters c1, c2, c3 and
> c4.
> I noticed the web method can take parameters as if it were a VB
> procedure, but this is going to be an XML formatted document coming
> from a server that is in Java code (can't modify that code, even if I
> knew a lick of Java).
> Can someone help me? I keep searching the help, but I get a ton of
> articles that just happen to have the words in them, rather than
> something specific.
> Would greatly appreciate it. Also, unless I have to, I would like to
> avoid XSLT in order to be able to do this in the Standard Edition.
Hi Brent
Look at the following sample
http://samples.gotdotnet.com/quicks...ngservices.aspx
Hope it helps
Hi, Brent.
Scott Mitchell's 10-article series on Web Services will help you understand
what you need to know in order to develop the web service you want:
http://aspnet.4guysfromrolla.com/articles/111903-1.aspx
Go completely through the 10 articles. There's a lot of sample code in them.
When you're done, you'll be in good shape to write your own web service to f
it your needs.
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
======================================
"Brent White" <bwhite@.badgersportswear.com> wrote in message
news:1184266659.728254.242650@.n2g2000hse.googlegroups.com...
> We're trying out Visual Studio 2005 Professional from the Microsoft
> website before paying for the unlocked version.
> What I am trying to do is build on the simple ASP.NET web service.
> HelloWorld is great, and I kind of see how it works.
> What I can not comprehend is how to build an actual ASP that will take
> an XML input, parse it, send the data to an external website as an
> HTTP request, then parse the response, and send it back to the client
> (actually another server).
> Let's say you have a web method that takes parameters p1, p2, and p3.
> It would then send an HTTP request (the external service can't take
> XML for some weird reason) with parameters a1, a2, a3, a4 and a5.
> When the response comes back, it would get parameters b1, b2 and b3
> and return to the client the response with parameters c1, c2, c3 and
> c4.
> I noticed the web method can take parameters as if it were a VB
> procedure, but this is going to be an XML formatted document coming
> from a server that is in Java code (can't modify that code, even if I
> knew a lick of Java).
> Can someone help me? I keep searching the help, but I get a ton of
> articles that just happen to have the words in them, rather than
> something specific.

> Would greatly appreciate it. Also, unless I have to, I would like to
> avoid XSLT in order to be able to do this in the Standard Edition.
On Jul 12, 5:49 pm, "Juan T. Llibre" <nomailrepl...@.nowhere.com>
wrote:
> Hi, Brent.
> Scott Mitchell's 10-article series on Web Services will help you understa=
nd
> what you need to know in order to develop the web service you want:
> http://aspnet.4guysfromrolla.com/articles/111903-1.aspx
> Go completely through the 10 articles. There's a lot of sample code in th=
em.
> When you're done, you'll be in good shape to write your own web service t=
o fit your needs.
> Juan T. Llibre, asp.net MVP
> asp.net faq :http://asp.net.do/faq/
> foros de asp.net, en espa=F1ol :http://asp.net.do/foros/
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
3D"Brent White" <bwh...@.badgersport=
swear.com> wrote in message
> news:1184266659.728254.242650@.n2g2000hse.googlegroups.com...
>
>
>
>
>
>
>
e quoted text -
> - Show quoted text -
Alexi and Juan, thank you. I'll look into these. I think if I make
a structure and pass the parameters using the SOAP interface to set
this up, it should be sufficient. I do like VS 2005, I will say that.

Saturday, March 24, 2012

Please help- can;t stop getting emails!

Ok, this is no good. I wrote an email program and when I tested it it went into some kind of endless loop and now it wont stop emailing. Ive closed the web app and everything and I just keep getting emails. I didnt even run the program very long. Ive gotten over 10,000 emails so far. Does anybody know how to cut off a loop like that???If I see the code, probably I can tell you!

As you said, if it is goine to end less loop, it might send those many emails and that's why you are keep getting emails, eventhough you close the page, what ever the mails sent before will be transfered or sent to the corresponding email through SMTP!
ok, here is my code: (i finally stopped getting emails after receiving about 35,000, literally.)


public void TestGroupEmail()
{
SqlDataReader objDR;

SqlConnection conds = new SqlConnection (ConfigurationSettings.AppSettings["con"]);
SqlCommand cmdNewsletter = new SqlCommand( "Select Email From EmailTest", conds); //there should be about 690 email addresses
conds.Open();
objDR = cmdNewsletter.ExecuteReader(System.Data.CommandBehavior.CloseConnection);

int intSIZE = 50;
int intBLOCK = 0;
Hashtable ht = new Hashtable();

while (objDR.Read())
{
for (int POS = 0; POS <= intSIZE; POS++)
{
intBLOCK += 1;
string strBLOCK = (objDR ["Email"] + ";");
strBLOCK = strBLOCK.Substring(0, strBLOCK.Length -1);
strBLOCK.Trim();

ht.Add(intBLOCK.ToString(), strBLOCK );
}
}

for (int i = 0; i <= ht.Count; i++)
{
System.Web.Mail.MailMessage objEmail = new System.Web.Mail.MailMessage();
objEmail.To = "************";
objEmail.From = "**********";
objEmail.Bcc = ht.Values.ToString();
objEmail.Subject = "This is the Test Email Subject." + ht.Keys.ToString(); //This actually doesnt gove me the value of the keys, either
objEmail.Body = "This is the test email body.";
objEmail.BodyFormat = System.Web.Mail.MailFormat.Html;
System.Web.Mail.SmtpMail.SmtpServer = "localhost";
System.Web.Mail.SmtpMail.Send(objEmail);
objEmail = null;
}

}


I took off the emails and just ran a response.write, ht.Count and it gave me 34,782

Thats a huge number of values/ I cant figure out why its like that...
Hint: Approximately 690 possible EMail addresses * 50 = 34,500

Solution: Look VERY carefully at whats happening during the inner loop on POS. Rather than getting up to fifty different EMails on the BCC line of each EMail, you are getting 50 duplicates of each and every EMail added to the hashtable. Note also that your string concatination of multiple EMail addresses (which are actually all the same) separated by semi-colons is not working either either as a new strBlock is created each time through the inner loop.

As far as code added to the EMail subject for debugging, I'm not sure that Keys.ToString is even defined as a valid method. It most likely does not produce a string containing a list of the hashtable keys.
How many records are in the database?

Also for each record you are looping through 51 times, means you migh have more than 682 records in DB, each record you are counting 51 times, that's why you are getting 34,782 as count!!!

I was not sure why you are adding each record 51 times to the ht table?
If you have 682 records in that table, then that's why you are getting that much count!!!

Wednesday, March 21, 2012

Please help me format my email!

Well I guess they say third times a charm so this is the third time Ive posted here and maybe someone will reply..
OK First off two things you should know:
1) This is my first ever .NET Website. Ever.
2) I'm using Visual Studio .NET 2003 with SQL Server 2000 deveoped under Windows 2000. The site is hosted under Windows Server 2003 so therefore I cannot test the email functionality in my dev environment because it does not support the email method that 2003 Server does...

Any way, I have a page where users send me an Email which contains data taken from their profiles. When I get it, it looks like this:

Web Part Request: Thursday, December 11, 2003 - 7:53:06 AM 1986 Mercedes-Benz 300E Engine: 6 Tran: A Turbo: N A/C: Y Fourwheel: 2 -------------------- I sent disc brakes back friday the 5th through u.s.p.s. for exchange for correct size .I also need timing chain tensioner,I have a timing chain and link and a gasket.

How can I format the email so its not so confusing? I need it to look like this:

Web Part Request: Thursday, December 11, 2003 - 7:53:06 AM
1986 Mercedes-Benz 300E
Engine: 6
Tran: A
Turbo: N
A/C: Y
Fourwheel: 2
--------------------
I sent disc brakes back friday the 5th through u.s.p.s. for exchange for correct size .I also need timing chain tensioner,I have a timing chain and link and a gasket.

Thanks a lot for your time!
Regards,
Joe

Here is the snippet of code for the page and in case you're wondering, I didnt write this part (hence the reason Im asking for help, a coworker who is no longer here set up the basics):


If Not IsPostBack Then

Dim sessionmember As diyauto.diymember.diymemberdetail = New diyauto.diymember.diymemberdetail
sessionmember = Session("userinfo")

If sessionmember Is Nothing Then
Session("loginreturnpage") = "/partfinder/partrequest.aspx"
Response.Redirect(ConfigurationSettings.AppSettings("SiteHomePage") + "/member/loginagain.aspx")
End If

' show the user name
lblName.Text = Trim(sessionmember.firstname) & " " & (Trim(sessionmember.middlename) & " ") & Trim(sessionmember.lastname)

Dim carid As Integer
carid = Val(Request.QueryString.Get("c"))

If carid = 0 Then
Response.Redirect("partlocator.aspx")
End If

Dim carfunct As diymember.diymembercarfunctions = New diymember.diymembercarfunctions
Dim mycar As diymember.diymembercardetail = New diymember.diymembercardetail

mycar = carfunct.carinfoget(sessionmember.memberid, carid)

'if there is nothing here - send them back!
'Response.Redirect("partlocator.aspx")
If mycar Is Nothing Then
Response.Redirect("partlocator.aspx")
End If

lblCarInfo.Text = mycar.year.ToString + " - " + RTrim(mycar.makename) + " " + RTrim(mycar.modelname) + " Engine: " + mycar.engine + " Tran: " + mycar.autotransmission + " Turbo: " + mycar.turbo + " A/C: " + mycar.aircondit + " Fourwheel: " + mycar.fourwheel + " VIN: " + RTrim(mycar.vin)
hidlabCarInfo.Text = mycar.year.ToString + " " + RTrim(mycar.makename) + " " + RTrim(mycar.modelname) + vbCr + "Engine: " + mycar.engine + vbCr + "Tran: " + mycar.autotransmission + vbCr + "Turbo: " + mycar.turbo + vbCr + "A/C: " + mycar.aircondit + vbCr + "Fourwheel: " + mycar.fourwheel + vbCr + "VIN: " + RTrim(mycar.vin)

End If

End Sub

Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click

If Len(LTrim(RTrim(tbxRequest.Text))) = 0 Then
lblError.Text = "Please indicate the parts you're Looking for!"
Return
End If

Dim sessionmember As diyauto.diymember.diymemberdetail = New diyauto.diymember.diymemberdetail
sessionmember = Session("userinfo")

If sessionmember Is Nothing Then
Session("loginreturnpage") = "/member/myaccount.aspx"
Response.Redirect(ConfigurationSettings.AppSettings("SiteHomePage") + "/member/loginagain.aspx")
End If

' lets prepare an e-mail and send it along to the parts folks!

Dim Maildiy As New System.Web.Mail.MailMessage
Maildiy.From = RTrim(sessionmember.email)
Maildiy.To = "joe@dotnet.itags.org.diyautoparts.com"
Maildiy.Subject = "WEBSITE PARTS REQUEST"
Maildiy.BodyFormat = Mail.MailFormat.Text
Maildiy.Body = "Web Part Request: " + DateTime.Now.ToLongDateString + " - " + DateTime.Now.ToLongTimeString + vbCr + vbCr + hidlabCarInfo.Text + vbCr + vbCr + "--------------------" + vbCr + vbCr + RTrim(tbxRequest.Text)
System.Web.Mail.SmtpMail.Send(Maildiy)
Maildiy = Nothing

' send an e-mail to the sender!
Dim MailCust As New System.Web.Mail.MailMessage
Dim replytext As String

MailCust.From = "parts@dotnet.itags.org.diyautoparts.com"
MailCust.To = RTrim(sessionmember.email)
MailCust.Subject = "DIYAUTOPARTS.COM - Part Request from Website"
'replytext = "Thank you for requesting car part information from DiyAutoparts.com. Your request has been entered into our system and we will contact you as soon as we have information for you." + vbCr + vbCr + "Our office hours are Monday - Friday 8:00am - 4:30pm EST." + vbCr + vbCr
'replytext += "Web Request time: " + DateTime.Now.ToLongDateString + " - " + DateTime.Now.ToLongTimeString + vbCr + vbCr
'replytext += hidlabCarInfo.Text + vbCr + vbCr + "------------------" + vbCr + vbCr + RTrim(tbxRequest.Text) + vbCr

MailCust.BodyFormat = Mail.MailFormat.Text

MailCust.Body = "Thank you for requesting car part information from DiyAutoparts.com. Your request has been entered into our system and we will contact you as soon as we have information for you." + vbCr + vbCr + "Our office hours are Monday - Friday 8:00am - 4:30pm EST." + vbCr + vbCr
MailCust.Body += "Web Request time: " + DateTime.Now.ToLongDateString + " - " + DateTime.Now.ToLongTimeString + vbCr + vbCr
MailCust.Body += hidlabCarInfo.Text + vbCr + vbCr + "------------------" + vbCr + vbCr + RTrim(tbxRequest.Text) + vbCr

'MailCust.Body = replytext
System.Web.Mail.SmtpMail.Send(MailCust)
MailCust = Nothing

Response.Redirect("partlocatorsub.aspx")

End Sub

Private Sub btnQuit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnQuit.Click
Response.Redirect("partlocator.aspx")
End Sub

Private Sub btnMyAcct_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMyAcct.Click
Response.Redirect(ConfigurationSettings.AppSettings("SiteHomePage") + "/member/myaccount.aspx")
End Sub
End Class

How about just adding some vbCrLf characters in there where you want the line breaks?

Friday, March 16, 2012

please help me with ASP.net problems

Dear Sirs,

I'm a Vietnamese student. I've been developing a website for my school; as not a professional web programer, I have some problems using the language ASP.net. I'd be grapeful if you'd help me to solve some of the following troubles:

- I use a tool on left-hand toolbar called "file field" to upload a picture to a folder on the web server but I don't know what commands to be used to delete it from this folder?

- I call a confirmation box (in VB language) but I receive an error message: "It is invalid to show a modal dialog or form when the application is not running in UserInteractive mode"?

- What commands to hide or disable the back & next buttons in web browser?

Thank you for your help !

Luong trung Kien

Wellcome on asp.net forums.....
Here are your answers
1 - u use Input/output libarary , here is the reference ... http://aspnet.4guysfromrolla.com/articles/051802-1.aspx
2 - In Windows base application use, MsgBox(Prompt, Buttons,Title)
and in Web based application used Javascript message box
also see this link for reference , http://www.programmersheaven.com/mb/VBNET/161205/161205/readmessage.aspx
3 - simply used this command in code behind, BUTTON_NAME.visible = False (for hide) & BUTTON_NAME.enabled = False (For Disabled), and also u can perform this activity through designer.........

Happy Programming !
Sajjad

Hi,

The answers to your first and second questions are given above.

But for 3) - There is no way of disabling the back/forward button in a web browser, and nor should you try! The back/forward buttons are so important to web browsing that no web application should function without them. Most users on the web rely on the back/forward buttons for navigation - you should think of them as an asset rather than a problem.

Rich