Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 1st, 2009, 09:10 AM
Friend of Wrox
Points: 752, Level: 10
Points: 752, Level: 10 Points: 752, Level: 10 Points: 752, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2009
Posts: 165
Thanks: 5
Thanked 6 Times in 6 Posts
Arrow update panel

Hello sir,
I am working on contact.aspx page. I am using update panel with it to show the waiting image. It is working fine. But when I use the file attachment to it then file does not get sent with the message, but if I remove the update panel then it works fine.

my code for the markup (ContactForm.ascx) is

Code:
<asp:UpdatePanel ID="UpdatePanel1" runat ="server" >
<ContentTemplate >
<table class="style1" runat="server" id="FormTable">
    
same as in book. The extra field is file upload...

        <td align="right" class="style16">
            Attach Your File ( If Any ):</td>
        <td class="style5">
            <asp:FileUpload ID="FileUpload1" runat="server" Font-Bold="True" 
                Font-Italic="True" ForeColor="#39561D" />
        </td>
        <td class="style15">
        </td>
    </tr>
    <tr>
        <td class="style3" align="right">
            &nbsp;</td>
        <td class="style2">
         
           <asp:Button ID="btnSend" runat="server" Text="Submit Feedback" Font-Bold="True" Font-Italic="True" 
                ForeColor="#39561D" />
        </td>
        <td>
            &nbsp;</td>
    </tr>
    <tr>
        <td class="style7" colspan="3">
            <asp:ValidationSummary ID="ValidationSummary1" runat="server" 
                HeaderText="Please Correct The Following Errors Before You Press The Button" 
                Height="156px" Font-Bold="True" Font-Italic="True" ShowMessageBox="True" />
        </td>
    </tr>
</table>
<asp:Label ID="lblMessage" runat="server" Text="Message Sent" Visible="false"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID ="UpdatePanel1">
<ProgressTemplate >
<div class="PleaseWait">Please Wait...</div>
</ProgressTemplate>
</asp:UpdateProgress>
And the code behind file is

Code:
Protected Sub btnSend_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSend.Click
        If Page.IsValid Then

            Dim fileName As String = Server.MapPath("~/App_Data/FeedbackForm.txt")
           

            Dim mailBody As String = System.IO.File.ReadAllText(fileName)
            mailBody = mailBody.Replace("##Name##", txtName.Text)
            mailBody = mailBody.Replace("##Email##", txtEmailAddress.Text)
            mailBody = mailBody.Replace("##HomePhone##", txtPhoneHome.Text)
            mailBody = mailBody.Replace("##BusinessPhone##", txtPhoneBusiness.Text)
            mailBody = mailBody.Replace("##Comments##", txtComments.Text)

            Dim myMessage As New MailMessage()
            myMessage.Subject = "Feedback From Web Site"
            myMessage.Body = mailBody
            
            myMessage.From = New MailAddress("You@yourprovider.com", "Name")
            myMessage.To.Add(New MailAddress("You@yourprovider.com", "Name"))

            If FileUpload1.HasFile Then
                Dim fileName1 As String = Path.GetFileName(FileUpload1.PostedFile.FileName)
                Dim myAttachment As New Attachment(FileUpload1.FileContent, fileName1)
                myMessage.Attachments.Add(myAttachment)
            End If
            Dim mySmtpClient As New SmtpClient()
            Try
                mySmtpClient.EnableSsl = True
                mySmtpClient.Send(myMessage)
            Catch ex As Exception
                'ex.Message.ToString();
                lblMessage.Text = "Sorry,An Error Occurred While Sending Your Message. Please Try Again."
            End Try

            lblMessage.Visible = True
           
            FormTable.Visible = False
        End If
    End Sub
Any help is most appreciated.
Thank you.
Reply With Quote
  #2 (permalink)  
Old December 1st, 2009, 09:42 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

You'd be surprised to learn what a Google search for "UpdatePanel FileUpload" (incidentally, the two controls you're working with) brings you:

http://www.google.com/search?hl=en&s...oq=&aqi=g3g-m2

Voila; instant results. The two are, by design, not compatible. But if you read on you'll find some work arounds including the AsyncFileUpload control.

In other words: GIYF, or STFW..... ;-)

How hard can it be....

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
  #3 (permalink)  
Old December 1st, 2009, 01:24 PM
Friend of Wrox
Points: 752, Level: 10
Points: 752, Level: 10 Points: 752, Level: 10 Points: 752, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2009
Posts: 165
Thanks: 5
Thanked 6 Times in 6 Posts
Arrow

Hello sir,
thank you for previous post. Now file Uploading is working fine but another issue comes into picture. Now updateprogress is not working. The link you provided, recommends about using trigger, but having triggers used update progress does not work.
Code:
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID ="btnSend" />
</Triggers>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID ="UpdatePanel1">
<ProgressTemplate >
    <div class="PleaseWait">Please Wait...</div>
</ProgressTemplate>
</asp:UpdateProgress>
I made many searches on this but no useful answer was there.
Any suggestion????
Thank you once again.

Last edited by jack_hilary; December 1st, 2009 at 01:27 PM..
Reply With Quote
  #4 (permalink)  
Old December 1st, 2009, 01:41 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

You're doing a full post back now....

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
  #5 (permalink)  
Old December 1st, 2009, 04:26 PM
Friend of Wrox
Points: 752, Level: 10
Points: 752, Level: 10 Points: 752, Level: 10 Points: 752, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2009
Posts: 165
Thanks: 5
Thanked 6 Times in 6 Posts
Arrow

Yes It is full post post back but these two tasks do not seem to be compatible. If I use trigger then progress does not work. So is there any way to use both????

Thank you sir once again.
Reply With Quote
  #6 (permalink)  
Old December 1st, 2009, 04:33 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Did you read my previous post? Did you follow the Google link? Did you read the first 20 odd results? Did you Google to find out what the AsyncFileUpload control is?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Gridview Update not firing in Update Panel akshay144 Ajax 1 August 13th, 2009 10:20 AM
Dropdown in update panel deb1980 ASP.NET 2.0 Professional 0 June 16th, 2009 06:42 AM
Update panel in .net 2.0 DIlip Kumar Sittu .NET Framework 2.0 1 July 18th, 2008 06:44 AM
Javascript Update Panel. blink18jew ASP.NET 1.0 and 1.1 Basics 0 June 30th, 2007 06:46 AM



All times are GMT -4. The time now is 10:56 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.