SEARCH YOUR SOLUTION HERE  

Sending Mail Using .NET

Hi ,
I have scanning thru on topics of sending mails using
.NET. I have tried the below code for sending mails .
This issue is that mails cannot be sent.

Dim mail As New MailMessage()
mail.To = "tovalidmail@mail.com"
mail.From = "fromvalidmail@mail.com"
mail.BodyFormat = MailFormat.Text
mail.Subject = "Subject of this Email"
mail.Body = "Body of this message."
SmtpMail.SmtpServer = "localhost"

SmtpMail.Send(mail)

-----------------------------
Also no error is displayed but mail is nor sent

Query
1) This code is run on my home PC Win2k server
would the above code be able to send mails using the
local SMTP server on my machine Or does it require
a dedicated Exchange Server setup.

Posted On: Tuesday 1st of January 2013 10:17:49 PM Total Views:  752
View Complete with Replies




Related Messages:

Questions In JAVA   (107 Views)
I am trying to automate login process, i want to retrieve the next page after login....Kindly help me with this problem...
Sending an Email using Smtp server or...?   (244 Views)
HiI'm trying to send an email in a asp.net application. I used the following code but I encounter an error. Please help me.Code:Imports System.Web.Mail.SmtpMailCode: Private Sub Btnlogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnlogin.ClickCode:Dim objmail As System.Web.Mail.SmtpMailCode:objmail.Send(Txtemail.Text, Txtto.Text, "Subject", TxtBody.Text)Code: End SubThank you in advanceVbseyyed:thumb:
Help with a dataview grid   (217 Views)
I'm not sure what all is needed but this is the code behind the design view for this page. Basically it works however when I start up the page instead of the dataview grid being empty until I run a customer ID, it instead shows the numbers 27,28,29 through 43. Then when I run my customerID number it still shows those numbers yet it also shows what it is supposed to below those numbers. I can't figure out where in the world these numbers are coming from when I run the page. Imports System.Data Partial Class CustomerSurvey Inherits System.Web.UI.Page Dim dvTable As DataView Protected Sub btnGetIncidents_Click(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles btnGetIncidents.Click dvTable = CType(AccessDataSource1.Select( _ DataSourceSelectArguments.Empty), DataView) dvTable.RowFilter = "CustomerID = " & txtCustomerID.Text _ & " And DateClosed Is Not Null" If dvTable.Count > 0 Then Me.DisplayClosedIncidents() EnableControls(True) ' lstIncidents.Focus() Else lblNoIncidents.Text = "There are no incidents for that customer." EnableControls(False) End If End Sub Private Sub DisplayClosedIncidents() lstIncidents.Items.Add(New ListItem("--Select an incident--", "None")) For Each drvRow As DataRowView In dvTable Dim incident As New Incident incident.IncidentID = CInt(drvRow("IncidentID")) incident.ProductCode = drvRow("ProductCode").ToString incident.DateClosed = CDate(drvRow("DateClosed")) incident.Title = drvRow("Title").ToString lstIncidents.Items.Add(New ListItem( _ incident.CustomerIncidentDisplay, incident.IncidentID)) Next lstIncidents.SelectedIndex = 0 lblNoIncidents.Text = "" End Sub Private Sub EnableControls(ByVal enable As Boolean) lstIncidents.Enabled = enable lblHeading.Enabled = enable lblResponseTime.Enabled = enable rblResponseTime.Enabled = enable lblEfficiency.Enabled = enable rblEfficiency.Enabled = enable lblResolution.Enabled = enable rblResolution.Enabled = enable lblComments.Enabled = enable txtComments.Enabled = enable chkContact.Enabled = enable rdoContactByEmail.Enabled = enable rdoContactByPhone.Enabled = enable btnSubmit.Enabled = enable End Sub Protected Sub btnSubmit_Click(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles btnSubmit.Click If Page.IsValid Then Dim survey As New Survey survey.CustomerID = txtCustomerID.Text survey.IncidentID = lstIncidents.SelectedValue If rblResponseTime.SelectedIndex -1 Then survey.ResponseTime = rblResponseTime.SelectedValue End If If rblEfficiency.SelectedIndex -1 Then survey.TechEfficiency = rblEfficiency.SelectedValue End If If rblresolution.SelectedIndex -1 Then survey.Resolution = rblresolution.SelectedValue End If survey.Comments = txtComments.Text If chkContact.Checked Then survey.Contact = True If rdoContactByEmail.Checked Then survey.ContactBy = "Email" Else survey.ContactBy = "Phone" End If Session.Add("Contact", True) Else survey.Contact = False Session.Add("Contact", False) End If 'REDIRECT TO THE WEB PAGE SurveyComplete.aspx Response.Redirect("SurveyComplete.aspx") End If End Sub Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load txtCustomerID.Focus() End Sub End Class
Online Exam Portal Development   (161 Views)
Please help me to solve my problem i m new to Asp.Net I want to develop application for online Exam using sql database and also want to include timer in it
Need helpp Score Function in Quiz Software   (224 Views)
I've tried using viewstates but these are not used at the moment im trying to track the questionnumber and score the answers choosen, hope some one can help me. i just need a score function please. txtSystemAnswer.Text = "" lblUserName.Text = "John Doe" lblExamineeName.Text = "Charlie Brown's A Dummy" 'Put user code to initialize the page here Dim sysAnswer As String Dim usAnswer As String Dim TrackQuestNum As Integer 'lblTrackNum.Text = TrackQuestNum 'Assign Tracking num to lblTrackNum 'Receive PK/Index for WHERE STATEMENT 'Me.ReceivingIndex = Val(A_form.ReceivedIndex) Me.ReceivingIndex = 1 'This holds ForeignKey value! 'Me.InitializeComponent() 'Call RadioButton Blanking Me.BlankOutRadio() Try Me.SqlConnection1.Open() 'Me.SqlSelectCommand1.CommandText = "Select * From TBL_ExamQuestions WHERE ExamID = ' " & iRecievedIndex & " ' AND QuestionNum = ' " & thispage & " ' ORDER BY QuestionID ASC" Me.SqlSelectCommand1.CommandText = "Select * From TBL_ExamQuestions WHERE ExamID = ' " & ReceivingIndex & " ' ORDER BY QuestionNum ASC" ' Me.DataSet111.Tables("TBL_ExamQuestions").Clear() Me.SqlDataAdapter1.SelectCommand = Me.SqlSelectCommand1 Me.SqlDataAdapter1.Fill(Me.DataSet111, "TBL_ExamQuestions") Me.DataSet111.Clear() Me.SqlDataAdapter1.Fill(DataSet111) Me.lblQuestNo.DataBind() Me.TextBox1.DataBind() 'QuestionBox Me.lblSystemAnswer.DataBind() Me.txtSystemAnswer.DataBind() Me.RadioButton1.DataBind() Me.RadioButton2.DataBind() Me.RadioButton3.DataBind() Me.RadioButton4.DataBind() Me.CheckRadioButtons() theSystemAnswer = Val(lblSystemAnswer.Text) theUserAnswer = Val(MyChoice) 'Save Data on temp ViewStates ViewState("CybertronAnswer") = theSystemAnswer 'SysetmAnswer! ViewState("OmegatronAnswer") = theUserAnswer 'UserAnswer ViewState("TotalQuestion") = intTotalQuestion ViewState("Score") = intScore ViewState("QuestionNo") = intQuestionNo 'ViewState("AnswerHistory") = arrAnswerHistory Me.txtSystemAnswer.Text = theSystemAnswer Catch ex As Exception ' No code YET! Finally End Try End Sub Public Sub btnNextQuest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNextQuest.Click Dim abc As String Dim index As Integer Dim TrackQuestNum As Integer Dim ThisScore As Integer theSystemAnswer = ViewState("CybertronAnswer") theUserAnswer = ViewState("OmegatronAnswer") intTotalQuestion = ViewState("TotalQuestion") intScore = ViewState("Score") intQuestionNo = ViewState("QuestionNo") 'arrAnswerHistory = ViewState("AnswerHistory") If theUserAnswer = theUserAnswer Then Me.lblUserName.Text = "Something went in!" Application.Item("ThisScore") = Application.Item("ThisScore") + ThisScore Me.lblYourScore.Text = Application.Item("ThisScore") Else Me.lblUserName.Text = "Its not equal" End If Me.ShowNextQuestion(intQuestionNo) 'Load next question! Me.BlankOutRadio() 'Call RadioButton Blanking! End Sub Public Sub ShowNextQuestion(ByVal intQuestionNo As Integer) Dim abc As String Dim index As Integer Dim TrackQuestNum As Integer Dim usAnswer As String Dim sysAnswer As String If theUserAnswer = theUserAnswer Then Me.lblUserName.Text = "Something went in!" Application.Item("ThisScore") = Application.Item("ThisScore") + thisScore Me.lblYourScore.Text = Application.Item("ThisScore") Else Me.lblUserName.Text = "Its not equal" End If index = Me.ViewState("index") index += 1 If index > DataSet111.Tables(0).Rows.Count - 1 Then index = DataSet111.Tables(0).Rows.Count - 1 'index = 0 End If Me.ViewState("index") = index 'stores the number to viewstate abc = DataSet111.Tables(0).Rows(index).Item("TheQuestion") DataView1.Sort = "QuestionNum" DataView1.RowFilter = "TheQuestion='" & abc & "'" Me.TextBox1.DataBind() Me.lblQuestNo.DataBind() Me.txtSystemAnswer.DataBind() Me.lblSystemAnswer.DataBind() Me.RadioButton1.DataBind() Me.RadioButton2.DataBind() Me.RadioButton3.DataBind() Me.RadioButton4.DataBind() Do ViewState("CybertronAnswer") = theSystemAnswer ViewState("TotalQuestion") = intTotalQuestion ViewState("Score") = intScore ViewState("QuestionNo") = intQuestionNo Loop While (ViewState("index") = index) End Sub Sub CheckRadioButtons() 'Check Radio Button Inputs!!!! ' Me.ViewState("Ans1") = ans1 ' Me.ViewState("Ans2") = ans2 If RadioButton1.Checked Then Me.lblYourAnswer.Text = "A" MyChoice = "A" ElseIf RadioButton2.Checked Then Me.lblYourAnswer.Text = "B" MyChoice = "B" ElseIf RadioButton2.Checked Then Me.lblYourAnswer.Text = "C" MyChoice = "C" ElseIf RadioButton2.Checked Then Me.lblYourAnswer.Text = "D" MyChoice = "D" End If End Sub Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged If Page.IsPostBack Then MyChoice = "A" Me.lblYourAnswer.Text = "A" Me.thisUserAnswer = Me.lblYourAnswer.Text End If End Sub Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged MyChoice = "B" Me.lblYourAnswer.Text = "B" Me.thisUserAnswer = Me.lblYourAnswer.Text End Sub Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged MyChoice = "C" Me.lblYourAnswer.Text = "C" Me.thisUserAnswer = Me.lblYourAnswer.Text End Sub Private Sub RadioButton4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton4.CheckedChanged MyChoice = "D" Me.lblYourAnswer.Text = "D" Me.thisUserAnswer = Me.lblYourAnswer.Text End Sub Sub BlankOutRadio() 'Blank-Out the RadioButtons! Me.RadioButton1.Checked = False Me.RadioButton2.Checked = False Me.RadioButton3.Checked = False Me.RadioButton4.Checked = False End Sub This post has been edited by bryanarzaga: 09 October 2007 - 02:32 PM
Custom membership provider   (156 Views)
using vs 2005 and vb.net...I used the following article as a reference for creating a custom membership provider:http://www.devx.com/asp/Article/29256My implementation is a bit different, its using an sql database with a slightly different schema. But, it does function. It also authenticates users correctly except that any LoginStatus controls I use do not seem to notice that the user is authenticated. Logging in seems to work as in it gives me an error when I use an invalid login, and it continues on to the destinationUrl when I provide a valid login. Has anyone implemented a custom membership provider or have any idea why the loginstatus control would not be recognizing that I am logged i
error in text upload to database ????   (197 Views)
I was attempting to upload some text to the database and was encountering an error. I spend the better part of 8 hours trying to figure out what was wrong and have found that there was an ' in the text that was causing the error. I need the ability to save those as well as every other text to the database without any problems. So I am looking for any ideas that will help fix this issue.
Auto fill textbox   (233 Views)
I have a form that includes 2 text input. I'd like the second text input to fill with the value selected from database based on the first textbox value, by default when the first text input loses focus. What methods should I look into to learn to do thisplease help me as soon as possible....
posting info from one form to another   (202 Views)
I seem to be getting an error when I try to pass info from one page to another with a form This is my code........ Code: ' Insert page code here ' Sub SubmitForm(o As Object, e As EventArgs) Dim webbrowser webbrowser.Navigate("javascript:document.form.submit();") End Sub thats the working code, now postForm2.aspx looks like this: Code: Sub Page_Load If Not Page.PreviousPage Is Nothing Then Dim SourceTextBox As TextBox SourceTextBox = CType(PreviousPage.FindControl("theTextbox"), _ TextBox) If Not SourceTextBox Is Nothing Then Label1.Text = SourceTextBox.Text End If End If End Sub Should that not be able to pick up what is in theTextbox form field Cheers
Check Box Repeter Check Boxes in java Script   (162 Views)
Dear Coders Good Morning i know it has been long time i did not post any topic because of busy schedule anyhow Please i need to help me out , I have a repeter control that lodes within it some controls such as PageId (Literal), PageName(Literal), (checkBox), CanUserRead (checkBox), CanUserAdd (checkBox), CanUserUpdate (checkBox), CanUserDelete (checkBox), CanUserPrint (checkBox), CanUserViewHistory (checkBox), CanUserShowInMenu (checkBox), so these check boxes are in repeater and they implement security for each page in my application so a user may have permission on each page independently i tried to create javascript file to call if user clicks on the head of (Add) so all Check boxes in add Column are checked , but error is raised in java script file here is a diagram PageID PageName Read-Header(CheckBox)[] Add-Header (checkBox)[] . . . . . 1 ABC [] [] . . . . . 2 --- [] [] ......... so if user clicks on Read Header CheckBox all below (columns) relatives Read CheckBoxes are checked Also if also possible if i can add anothrt column names ALL so user clicks on that all Rows (relative checkBoxes are checked row by row ) for example -(Header) [] Read-Header [] andso on if use clicks a all current row check boxes are checked here is my attempts so far: function Check(checkBox ) { var frm = document.aspnetForm; var ChkState=checkBox.checked; for(i=0;i< 1000;i++) { e=frm.elements[i]; if(e.type=='checkbox' && e.name.indexOf('Id') != -1) e.checked= ChkState ; } } function CheckChanged() { var frm = document.aspnetForm; var boolChecked; boolChecked=true; for(i=0;i< frm.length;i++) { e=frm.elements[i]; if ( e.type=='checkbox' && e.name.indexOf('Id') != -1 ) if(e.checked== false) { boolChecked=false; break; } } for(i=0;i< frm.length;i++) { e=frm.elements[i]; if ( e.type=='checkbox' && e.name.indexOf('check') != -1 ) { if( boolChecked==false) e.checked= false ; else e.checked= true; break; } } }
error with script manager   (184 Views)
if this is using a master page, then you should be putting the ScriptManager on the master page, and then using the ScriptManagerProxy on the content pages. , do you receive this error message from the standard ASP.Net error page, or do you get an exception when running it in code Can you post the stack trace
Touch Screen Program   (179 Views)
how to Making a touch Screen Program
Write in XML file, asp.net vb.net   (221 Views)
! Well I have an aplication in asp.net vb.net, and I want to save something important writing in a xml file, but I want to write in this way: (key,value). In this momento I can write in comments, but I couldn't find the way to write with values and keys. If somebody can help me, would be great! This is my code: Imports System.Xml Dim textWriter As XmlTextWriter = New XmlTextWriter("C:\\myXmFile.xml", Nothing textWriter.WriteStartDocument() textWriter.WriteComment("My important thing") textWriter.WriteComment("myXmlFile.xml in root dir") textWriter.WriteEndDocument() Thank you!
Code to encrypt the Password or any string   (217 Views)
/// /// Thsi method retrieve the string to encrypt from the Presentation Layer /// And return the Encrypted String /// /// /// public string encryptPassword(string strText) { return Encrypt(strText, "&%#@,:*"); } /// /// This method retrieve the encrypted string to decrypt from the Presentation Layer /// And return the decrypted string /// /// /// public string decryptPassword(string str) { return Decrypt(str, "&%#@,:*"); } /// /// This method has been used to get the Encrypetd string for the /// passed string /// /// /// /// private string Encrypt(string strText, string strEncrypt) { byte[] byKey = new byte[20]; byte[] dv ={ 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF }; try { byKey = System.Text.Encoding.UTF8.GetBytes(strEncrypt.Substring(0, 8)); DESCryptoServiceProvider des = new DESCryptoServiceProvider(); byte[] inputArray = System.Text.Encoding.UTF8.GetBytes(strText); MemoryStream ms = new MemoryStream(); CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(byKey, dv), CryptoStreamMode.Write); cs.Write(inputArray, 0, inputArray.Length); cs.FlushFinalBlock(); return Convert.ToBase64String(ms.ToArray()); } catch (Exception ex) { throw ex; } } /// /// This method has been used to Decrypt the Encrypted String /// /// /// http://www.hanusoftware.com /// /// private string Decrypt(string strText, string strEncrypt) { byte[] bKey = new byte[20]; byte[] IV = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF }; try { bKey = System.Text.Encoding.UTF8.GetBytes(strEncrypt.Substring(0, 8)); DESCryptoServiceProvider des = new DESCryptoServiceProvider(); Byte[] inputByteArray = inputByteArray = Convert.FromBase64String(strText); MemoryStream ms = new MemoryStream(); CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(bKey, IV), CryptoStreamMode.Write); cs.Write(inputByteArray, 0, inputByteArray.Length); cs.FlushFinalBlock(); System.Text.Encoding encoding = System.Text.Encoding.UTF8; return encoding.GetString(ms.ToArray()); } catch (Exception ex) { throw ex; } } nospam.com
Problem in cmd.Parameters.AddWithValue("@l_no", l_no) Not gett   (159 Views)
I table viewyn and dept_letter. primary ket l_no ] protected void l_no_Click(object sender, EventArgs e) { // Fetch the customer id LinkButton lb = sender as LinkButton; string custID = lb.Text; lblCustValue.Text = custID; // Connection string constr = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["JAPITConnectionString"].ConnectionString; string sql = "SELECT * FROM Letter_dept WHERE l_no= @l_no"; SqlConnection connection = new SqlConnection(constr); connection.Open(); SqlCommand cmd = new SqlCommand(sql, connection); cmd.Parameters.AddWithValue("@l_no", l_no); cmd.CommandType = CommandType.Text; SqlDataReader dr = cmd.ExecuteReader(); // Bind the reader to the GridView // You can also use a lighter control // like the Repeater to display data GridView2.DataSource = dr; GridView2.DataBind(); connection.Close(); // Show the modalpopupextender ModalPopupExtender1.Show(); } Error is coming Error 1 The name 'l_no' does not exist in the current context
Email verification   (158 Views)
Sir,
online banking with aspdotnet technologies   (157 Views)
DSAD
drop down list box only read my first value   (154 Views)
hi, i pasted the code but it still doesn't work. i don't understand what is using the SelectedIndexChanged event of the Drop Down List to retrieve the value and load the data. Is it something i need to put in my code
how to use   (153 Views)
I need to display one of two placeholders depending on the value in . If the value is "open" i need one placeholder to show (), if the value is "forced" i need the other placeholder to show. () I think i need to use
Java Script in Asp.net   (122 Views)
Hi Everyone, i am trying open a popup window in pageload but its not taking the url to default.aspx string a= default.aspx; ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", "window.open( 'a', null, 'height=200,width=400,status=yes,toolbar=no,menubar=no,location=no' );", true); error: Url Appear as http://localhost:2031/a anyone help me in this issue
Error porblems   (222 Views)
HiI am new to .ASP net and have downloaded all i can and I am using MS Visual Web developer expresss 2010. I am following some training notes which is showing me how to add a controller but it doesnt seem to work.This is what the training notes tell me to doThis will create a new file, HomeController.cs, with the following code:using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Mvc;namespace MvcMusicStore.Controllers{public class HomeController : ControllerMVC Music Store Tutorial v2.0 http://mvcmusicstore.codeplex.com Tutorial under Creative Commons Attribution 3.0 LicensePage 14{//// GET: /Home/public ActionResult Index(){return View();}}}To start as simply as possible, let's replace the Index method with a simple method that just returns a string. We'll make two simple changes: Change the method to return a string instead of an ActionResult Change the return statement to return " from Home"The method should now look like this:public string Index(){return " from Home";}I create the Homecontroller but instead of naming it HomeController.cs it names it Homecontroller.vb.The code it creates for ma also looks different than above and I get thisNamespace MvcMusicStore Public Class HomeController Inherits System.Web.Mvc.Controller ' ' GET: /Home Function Index() As ActionResult Return View() End Function End ClassEnd NamespaceI have tried to change the programming and the function now looks like Function Index() As String{ return " from Home";} End FunctionI then get build errorsCan someone advise why iget .VB and not .CS and why my script is different and finally not working
Button after Sorting in Gridview   (233 Views)
I have a gridview with databinding in the .cs file.Also the soring events are handled there.I have added a button in the gridview colums and with the GridviewIndexChange events I get the row info which I clicked.BUT...when I sort the gridview, the info from this button seems to stays with it's old row, not the new sorted row.What can that be ...grtzLeoni
Setting up SQL DataBase in VWD   (169 Views)
How do i create a connection string to run on a remote server database to use with VWD using SQL2000
Unspecified error   (361 Views)
I was wondering if anyone else has had this problem before. I have been working on a site at work, and throughout the whole day it works fine, I am connected to the server at my machine at work. My problem is when I come home and start testing the site I get an"Unspecified Error" message and it says the my Conn.Open() statement is the problem. Just to really clarify this is where I open my connection to my access database. Does anyone know what I could be doing wrong
Removing leading tag   (179 Views)
,I store data with HTML tags and need to remove a leading tag if present.I tried a few things, also used the Server.HtmlDecode with no luck. How can I do thi
CompareValidator Controls   (211 Views)
HiI have an audit record form which shows before and after values for a given record.I've used CompareValidator controls to highlight which fields have changed.I want to see the message from the CV controls when the form is initially displayed - not after a postback.How can I achieve thi
com object   (248 Views)
will you invoke COM object from ASP.NET
ERROR: Unable to start debugging on web server   (170 Views)
I am new to ASP.Net. I am getting the following error whenever i am trying to run the project (F5). Unable to start debugging on web server. The server does not support debugginh of ASP.NET or ALT Server applications. Run setup to install the Visual Studio .NET server components. If setup has been run verify that a valid URL has been specified. Any suggestions Email: pankajmsm@yahoo.com
drop down events   (164 Views)
peoples of the forums.I am a little confused as to why my event handler is not fireing. I have a drop down list but the selected index event never fires. Does anyone know of problems with this or had it work for youmy event handler is as follows.Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChangedcode in hereEnd Su
form data validation   (233 Views)
, I am a beginner in asp.net trying to validate form data with validation controls.I read that the regular expression validator will not stop a textbox with just blanks or nothing in it from being submitted so a required field validator is needed to too. When I do this, a blank textbox shows an error message for each validator.(1) Is there a way of showing only the first error the controls find(2) If the data checking gets complicated, can programs be written in vb or c# be used for data checking instead of those validation controls(3) Would just doing (2) be better in the long run(4) When viewing the source of the aspx page I was struggling with, I saw Javascript but there is a runat="server" in the control. Is Javascript running at the server sideThankyou very much.
drag + drop labels   (258 Views)
, Im looking for a way that I can enable a label to be dragged and dropped (by the mouse) around a Panel that it is located within. Any ideas
Populating a Textbox field based on values of drop down lists   (255 Views)
I have two drop down boxes that are populated with a database. Below that I have a text box field, which is also pulling from the same table. This text box field needs to be automatically generated based on the values selected by the user in the two drop down lists. I know I need to set the postback property to true of the second drop down box, so that when the user selects something, it can trigger the text box to generate the value. But I have no idea what to do after that.Any input would be appreciated. Thank you!
Permission denied when i use fso to delete a file   (194 Views)
Hi if i upload a file using the following code, i am unable to delete it using another asp classic FSO.deletefile call.I keep getting permission denied. I think that it is not closing the file after the upload.CODEvoid Page_Load(Object sender, EventArgs e){} void UploadBut_Click(Object sender, EventArgs args){ decimal ImageWidth = Convert.ToInt32(Request.QueryString["imagewidth"]); decimal ImageHeight = Convert.ToInt32(Request.QueryString["imageheight"]); String preview = Request.QueryString["preview"]; String imgid = Request.QueryString["imgid"]; String FolderPath = Request.QueryString["folderpath"]; String Prefix = Request.QueryString["Prefix"]; String textbox = Request.QueryString["textbox"]; String dateStr = DateTime.Now.ToString("ddMMyyhhmmss"); String Extension = ConfigurationSettings.AppSettings["Extension"]; String MimeType = ConfigurationSettings.AppSettings["MimeType"]; long Quality = Convert.ToInt32(ConfigurationSettings.AppSettings["Quality"]); long MaxSize = Convert.ToInt32(ConfigurationSettings.AppSettings["MaxSize"]); String FilePath = Server.MapPath(FolderPath); String UploadedFile = PhotoUpload.PostedFile.FileName; int ExtractPos = UploadedFile.LastIndexOf("\\") + 1; //to retrieve only Filename from the complete path String UploadedFileName = UploadedFile.Substring(ExtractPos, UploadedFile.Length - ExtractPos); String ImageName = UploadedFileName; Stream ImageStream = PhotoUpload.PostedFile.InputStream; if (PhotoUpload.PostedFile.FileName != ""){ try{ System.Drawing.Image UploadedImage = System.Drawing.Image.FromStream(ImageStream); decimal oldHeight = UploadedImage.Height; decimal oldWidth = UploadedImage.Width; if(ImageHeight!=0 && ImageWidth!=0){ oldHeight = ImageHeight; oldWidth = ImageWidth; }else if(ImageHeight==0 && ImageWidth==0){ oldHeight = oldHeight; oldWidth = oldWidth; }else if(ImageHeight ImageWidth){ oldHeight = (ImageWidth / oldWidth) * oldHeight; oldWidth = ImageWidth; } }else if(ImageWidth ImageWidth){ oldWidth = (ImageHeight / oldHeight) * oldWidth; oldHeight = ImageHeight; } } int new_height = Convert.ToInt32(oldHeight); int new_width = Convert.ToInt32(oldWidth); using(Bitmap smallerImg = new Bitmap(new_width, new_height)){ Graphics g = Graphics.FromImage(smallerImg); g.SmoothingMode = SmoothingMode.HighQuality; g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.PixelOffsetMode = PixelOffsetMode.HighQuality; foreach (PropertyItem pItem in UploadedImage.PropertyItems){ smallerImg.SetPropertyItem(pItem); } g.DrawImage(UploadedImage, 0, 0, new_width, new_height); UploadedImage.Dispose(); EncoderParameters myParams = new EncoderParameters(1); DateTime MyDate = DateTime.Now; String MyString =Prefix+dateStr; //Quality = Quality - 10; myParams.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, Quality); //Response.Write(FilePath); smallerImg.Save(FilePath + MyString + Extension, GetEncoderInfo(MimeType), myParams); FileInfo fi = new FileInfo(FilePath + MyString + Extension); //smallerImg.Dispose(); decimal FileLen = (fi.Length / 1000); //myParams.Param[0].Dispose(); if (FileLen > MaxSize){ while (FileLen > MaxSize){ fi = new FileInfo(FilePath + MyString + Extension); FileLen = (fi.Length / 1000); if (FileLen > 1000){ Quality = Quality - 20; }else{ Quality = Quality - 10; } //MyString = MyDate.ToString("ddMMyyhhmmss"); myParams = new EncoderParameters(1); myParams.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, Quality); smallerImg.Save(FilePath + MyString + Extension, GetEncoderInfo(MimeType), myParams); myParams.Param[0].Dispose(); //Thread.Sleep(); } } } Response.Write("window.opener.document.getElementById('"+textbox+"').value='"+Prefix+dateStr+".jpg';\n"); if(preview!=""){ Response.Write("window.opener.document.getElementById('"+imgid+"').innerHTML='';\n"); Response.Write("window.opener.document.getElementById('"+imgid+"').href='"+preview+Prefix+dateStr+".jpg';\n"); } Response.Write("self.close()"); } finally {} }}private ImageCodecInfo GetEncoderInfo(String mimeType){ int j; ImageCodecInfo[] encoders; encoders = ImageCodecInfo.GetImageEncoders(); for (j = 0; j < encoders.Length; ++j){ if (encoders[j].MimeType == mimeType){ return encoders[j]; } } return null;} //Upload Image Choose an image to upload Click Add to continue }...the bane of my life!http://www.fuzzyd.co.uk
variable into session variable   (208 Views)
I have a table of values that have the same name as session variables. I'm trying to pass an item from the table into the code below to check the session variable. if session(" & rs1.Field(2).value & ") ="big" thenone of my session variables has the value big, but the if then doesn't fire. Does anyone see anything wrong with my syntaxp.s. I'm a newbie to asp.
button as image   (377 Views)
how can I change a button to show an image should still be a button but show an image that i set. what is the correct code for this
How do I put a flash movie on a web form?   (223 Views)
Hi. I would like to put a flash movie on a web form. Can anyone help me to do thi
passing a file over a network & compressing   (130 Views)
My asp application makes a downstream (using asp) of a text file. Because that file can be sometimes big >1mb sometimes the downstreams fail. I was wondering if it was possible to compress the file before its sending and then descompress it in the pther side.I realize that if I zip the file, the file becomes 70% smaller than the original size. So I would like to know if is possbible to downstream a pdf file. the machines have windows installed (I think zip comes with windows). Another solution would be to create a cab file. Is it possible tooAny exampleThank you
problem with application deployment   (206 Views)
Guys, I have a weird problem here. I'm trying to deploy my Web application to another development server. I created an installer via Web Setup in .Net, and it installed successfully. However, it won't update the datagrid. The ItemDataBound function is working, but if the user clicks the update or cancel buttons, nothing happens; the page just refreshes. It works fine on the server it was built on. Any idea what's going on her
datarelation with stored procedure   (201 Views)
I've got a problem with making a datarelation in asp.net. I've done it on other pages, but on this page, it just won't work which kept me staring myself blind on some code for the last hours.This is my code in vb.net:CODE'Set SQL Stored Procedure name... mSqlString = "exec klantGetKennis " ' Child - kennis => registratie dr1 = New DataRelation("kennisRegistratie", dc1, dc2, False) dr2 = New DataRelation("kennisUren", dc1, dc3, False) ds.Relations.Add(dr1) ds.Relations.Add(dr2) dv = ds.Tables("kennisverzekering").DefaultView If Not cn Is Nothing Then cn.Close() hgKennis.DataSource = dv hgKennis.DataBind()My stored procedure:CODECREATE PROCEDURE [florens].[klantGetKennis ] @KlantIdIn int AS/* get kennisgegevens */Select kennis.kennisverzekering_id , kennis.kennisverzekering_naam , kennis.kennisverzekering_begin_datum, kennis.kennisverzekering_eind_datum , kennis.kennisverzekering_contracturen, kennis.kennisverzekering_uurtarief From kennisverzekering as kennisWhere kennis.kennisverzekering_klant_id = @KlantIdIn/* get registration and coworkers,*/Select reg.kennisverzekering_registratie_id , reg.kennisverzekering_registratie_kennisverzekering_id, reg.kennisverzekering_registratie_datum , reg.kennisverzekering_registratie_uren , reg.kennisverzekering_registratie_omschrijving, reg.kennisverzekering_registratie_onsite , medewerker.medewerker_naam From kennisverzekering_registratie as regInner join kennisverzekering on reg.kennisverzekering_registratie_kennisverzekering_id = kennisverzekering.kennisverzekering_idInner join medewerker on reg.kennisverzekering_registratie_medewerker_id = medewerker.medewerker_id/* get hour total*/Select sum(registratie.kennisverzekering_registratie_uren) as som_uren, registratie.kennisverzekering_registratie_kennisverzekering_id From kennisverzekering_registratie as registratieGroup by registratie.kennisverzekering_registratie_kennisverzekering_idGOThe grid on the page is fairly straight-forward. It has all the fields, and as datakeyfield: kennisverzekering_id .I want to get all the kennisverzekeringen (difficult to explain, but some sort of Service Level Agreement with customers), related to the customers on my page. I want to see all the registrations, our coworkers (medewerkers) have made to these kennisverzekeringen. And very important, I want to see the sum of these registrations for each kennisverzekering.The error I get is:CODEfield or property with the name 'som_uren' was not found on the selected datasource. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Web.HttpException: A field or property with the name 'som_uren' was not found on the selected datasource.Source Error: Line 139:Line 140: hgKennis.DataSource = dvLine 141: hgKennis.DataBind()Line 142: MyGridDataGetKennis = TrueLine 143: End FunctionSource File: bla\grids\kennisverzekering.ascx.vb Line: 141 Stack Trace: [HttpException (0x80004005): A field or property with the name 'som_uren' was not found on the selected datasource.] System.Web.UI.WebControls.BoundColumn.OnDataBindColumn(Object sender, EventArgs e) +349 System.Web.UI.Control.OnDataBinding(EventArgs e) +66 System.Web.UI.Control.DataBind() +26 System.Web.UI.Control.DataBind() +86 System.Web.UI.WebControls.DataGrid.CreateItem(Int32 itemIndex, Int32 dataSourceIndex, ListItemType itemType, Boolean dataBind, Object dataItem, DataGridColumn[] columns, TableRowCollection rows, PagedDataSource pagedDataSource) +169 System.Web.UI.WebControls.DataGrid.CreateControlHierarchy(Boolean useDataSource) +1408 System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e) +49 System.Web.UI.WebControls.BaseDataList.DataBind() +23 backoffice.kennisverzekering.MyGridDataGetKennis() in bla\grids\kennisverzekering.ascx.vb:141 backoffice.kennisverzekering.Page_Load(Object sender, EventArgs e) in bla\grids\kennisverzekering.ascx.vb:32 System.Web.UI.Control.OnLoad(EventArgs e) +67 System.Web.UI.Control.LoadRecursive() +35 System.Web.UI.Control.AddedControl(Control control, Int32 index) +307 System.Web.UI.ControlCollection.Add(Control child) +153 backoffice.navbar.setPlaceHolder(String keuze) in bla\gui\navbar.ascx.vb:145 backoffice.navbar.onButtonClick(Object sender, EventArgs e) in bla\gui\navbar.ascx.vb:212 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33 System.Web.UI.Page.ProcessRequestMain() +1277A lot of code, but I hope someone sees what I'm doing wrong.Oh, btw, I've tried to change the sum field to some other field, but this didn't work either
Web Service Security   (189 Views)
I am relatively new to web services...I have created a service that posts appointments to a specified user's calendar. Now, that function requires some high security to work correctly...here is my current code... CODEPublic Function sendAppt() As String Dim iAppt As New CDO.Appointment Dim Conn As New ADODB.Connection Conn.Provider = "ExOLEDB.DataSource" Try With iAppt .StartTime = "#" & startTime & "#" .EndTime = "#" & endTime & "#" .Subject = Me.apptSubject .Location = Me.apptLocation .TextBody = Me.apptMessage .BusyStatus = CDO.CdoBusyStatusValues.cdoBusy .MeetingStatus = "Tentative" 'Save the appointment. Conn.Open("http://server.net/exchange/" & Me.mailTo & "/", "dustin", "dustin") .DataSource.SaveToContainer("http://vkmailtrain01.net/exchange/" & Me.mailTo & "/calendar", Conn) End With Return True Conn.Close() Catch err As Exception Return err.ToString Exit Function End Try End FunctionAt the point of Conn.Open is where, currently i'm setting the username and password...now they're not required for that call...is there a way to use IIS security to make this work I've tried to put in the user: dustin pwd: dustin into the anonymous access account in IIS...didn't do it... what am I missing any ideas would be great!!! "...we both know I'm training to become a cagefigher...see what happens if you try 'n hit me..."
asp.net connect to Access DB on mapped network drive   (178 Views)
I'm trying to connect an ASP.net page to an Access DB. At first I had the Access DB on the local server's C drive. Now I need to move Access to another server. I've mapped the folder where the DB was moved to network drive Z: on the asp.net server. And change the Data Source of the connection string to Z:/mydb.mdbNow it returns error: The Microsoft Jet database engine cannot open the file ''. It is already opened exclusively by another user, or you need permission to view its data. Is there another method to set this up Where I can have ASP.net/IIS on one server and have ADO connections to Access DB on another server. Thank you.
problem in retrieving records in dropdownlist box   (167 Views)
hi,My Code is given below...HTML Code--________________________________________________________ Denmark USA India _________________________________________________________ASP Code--__________________________________________________________Dim MyConnection As SqlConnectionDim MyCommand As SqlDataAdapterDim DS As DataSetMyConnection = New SqlConnection("Data Source=INFO3783;" _ & "Initial Catalog=GTD_Test;User Id=gtd;Password=gtd;" _ & "Connect Timeout=15;Network Library=dbmssocn;")MyCommand = New SqlDataAdapter("select * from GTD_M_ORG where LOCATION_ID=33", MyConnection)DS = New DataSet()MyCommand.Fill(DS)' according to above query 'USA' should be selected...i m using this line..cmbCountry.SelectedItem.Text = DS.Tables(0).Rows.Item(0).Item("COUNTRY_NAME")'but it adds a new item as 'USA'..i mean USA comes twice in the dropdownlist...it should come only once..________________________________________________________Thx in advance..
ASP.NET Windows Integrated Security   (223 Views)
This is the first time I'm useing Integrated Security, and I am probably missing something silly.I have IIS set to use Integrated Security and anonymous access is disabled.My web.config file is set to: This causes the login prompt to appear when accessing the web form, and I cannot log in. I don't think that it is doing any real authentication. When I "allow" a specific user and "deny" another, anybody can get in. Does anybody know what I could be missin
Image Webservice issue   (270 Views)
,Let me explain the setup of our servers first,We have a webserver sitting outside of the firewall, which runs the company site. We also have an internal webserver for our intranet. We also have a SQL server which, as guessed, sits inside our firewall. There is also a internal file server.Our internet webserver will query the database and get the path of some scanned documents for our customers. These documents are images and sit on the file server. Then, these images will be displayed on the site for our customers.Since, the webserver is outside of the firewall, we cannot attach any shared drives. Our solution: create a webservice that sits on the intranet webserver and gets the info for the internet webserver. I was reading up on the webservices info on the net, and noticed that the output of a webservice is always in XML. Is there any way that I can return a image file using the webserviceI know that this message is long. I do apologize for the length of this message and I appreciate all your help
Deleteing a Record and Passing a Record   (233 Views)
Tek-Tips, two questions for you...So, i've got an Access database driven online application.Pretty normal pretty simple stuff. I've got a delete function working just fine, but I find that when I make a record...let's say the Primary ID key is 7...if I delete that record then create a new record the next record's ID is going to be 8. I figure this is bad since evetually, although improbable the database even only with one record in it, could be at ID 10000000000 or whatever. Should I be concerned Also. I'm trying to create a link, that when clicked on goes to a "details" page for instance. Just like on monster.com when you click on the job it sends you too a bigger page with more details and information on it. How can I pass one record to a page and load only that one recordI hope I made sens
Attaching Files to emails problem   (115 Views)
Hi all,i have a form on my webpage that i want to allow users to attach two documents to there emails. I know how to attach files to emails using the .Net functions in the System.Web.Mail namespace but this entails the files sitting on the servers file system. I want to be able to attach emails that come from the client without having to buy a third party control. Has anyone got any ideas on how to do thisRob
Button Event not firing properly   (227 Views)
I seem to be having a problem that I can't figure out. I am fairly new to asp.net and am still getting my understanding down so this may be an easy answer question that I haven't been able to find an answer for.I have form which depending on which button is clicked it should either increase or decrease an integer by 1.It seems to work correctly the first time I click a button, but all subsequent clicks are either ignored or processed incorrectly.I have been trying to use the code behind method to do this, since I like it better, but I can't seem to get it to work.My code is below:WebForm3.aspx:CODE WebForm3   WebForm3.aspx.vbCODEPublic Class WebForm3 Inherits System.Web.UI.Page#Region " Web Form Designer Generated Code " 'This call is required by the Web Form Designer. Private Sub InitializeComponent() End Sub Protected WithEvents btnPrev As System.Web.UI.WebControls.Button Protected WithEvents btnNext As System.Web.UI.WebControls.Button Protected WithEvents lblCurrentValue As System.Web.UI.WebControls.Label '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 currvalue As Integer = 0 Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here End Sub Private Sub btnPrev_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrev.Click currvalue = currvalue - 1 lblCurrentValue.Text = Convert.ToString(currvalue) End Sub Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click currvalue = currvalue + 1 lblCurrentValue.Text = Convert.ToString(currvalue) End SubEnd ClassAny assistance that could be provided would greatly help move my project along
Joining tables in Dataset   (231 Views)
I need to join tables returned in a dataset.Please do not respond to do the join in SQL - suffice it to say - that aint gonna happen.As a sample - dataset will return 2 tablestable(0)CategoryID intCategoryName vartable(1)ItemID intItemName varCategoryID intI will need to join table0 with table1 on CategoryID. After all is said and done will be displaying Categoryname as top level and ItemName as next level in treeview.Can anyone give me a quick sample / overview of how this could be accomplishedThank you !! PHI was walking home one night and a guy hammering on a roof called me a paranoid little weirdo. In morse code. -Emo Phillips
Design idea/ code sample/ advice needed..   (239 Views)
Not sure if I'm on the right path here but this is what i want to do but not sure how to do it...I click on a button, go to the next page. On this page, I want to have 2 radio buttons. The RadioButton1 is the default and has for example 10 textboxes and a submit button with it.... When the Radio Button2 is clicked, i want to display another set of textboxes with a new submit button... so basically, going back and forth between the RadioButton1 and RadioButton2, displays different set of textboxes. How to go about doing this a sample code and/or just an idea on how to do it would be great.