Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics 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 February 20th, 2007, 03:10 PM
Registered User
 
Join Date: Feb 2007
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Page Refresh on first postback

I have a RadiobuttonList on a form, its autopostback enabled, but always on first postback the form is refreshed and lost the data, the second time it works... but the first!! it just refresh losing all data, Viewstate is also enabled, have an idea?

Reply With Quote
  #2 (permalink)  
Old February 20th, 2007, 03:15 PM
Friend of Wrox
 
Join Date: May 2006
Location: San Diego, CA, USA.
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

What is your code in the page load?

Woody Z
http://www.learntoprogramnow.com
How to use a forum to help solve problems
Reply With Quote
  #3 (permalink)  
Old February 20th, 2007, 06:05 PM
Registered User
 
Join Date: Feb 2007
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

already tried with the load_page method empty!! does the same!



Reply With Quote
  #4 (permalink)  
Old February 20th, 2007, 06:14 PM
Friend of Wrox
 
Join Date: May 2006
Location: San Diego, CA, USA.
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

So how do you load the data in the first place?

Woody Z
http://www.learntoprogramnow.com
How to use a forum to help solve problems
Reply With Quote
  #5 (permalink)  
Old February 20th, 2007, 08:22 PM
Registered User
 
Join Date: Feb 2007
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

well, by default my radiobuttonList have a option checked of the 4 options, and so the radiobuttonLIst_IndexChanged is called and load the right controls, here is the code:

 using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.Web.Mail;
    using System.Data.SqlClient;
    public partial class editors_NewsLetterControl : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            String result;
            try
            {
                SmtpMail.SmtpServer = "smtp.gmail.com";
                MailMessage mail = new MailMessage();
                mail.To = "mail@somemail";
                mail.From = "Custom subject";
                if (RadioButtonList1.SelectedValue == "Type 1 Enquiry")
                {
                    mail.Body = "Type 1 Enquiry \n\nEmail: " + emailTextBox.Text + "\n\n" + NewsLetterTextBox.Text;



                } if (RadioButtonList1.SelectedValue == "Type 2 Enquiry")
                {
                    mail.Body = "Type 2 Enquiry\n\nName: " + nameTextBox.Text.ToString() + "\nEmail: " + emailTextBox.Text + "\n\n" + NewsLetterTextBox.Text;

                }
                if (RadioButtonList1.SelectedValue == "Type 3 Enquiry")
                {
                    mail.Body = "Type 3 Enquiry \n\nName: " + nameTextBox.Text.ToString() + "\nCompany: " + companyTextBox.Text.ToString() + "\nPhone: " + phoneTextBox.Text.ToString() + "\nEmail: " + emailTextBox.Text + "\nWebsite: " + webTextBox.Text.ToString() + "\n\nMessage:\n\n" + NewsLetterTextBox.Text;

                } if (RadioButtonList1.SelectedValue == "Type 4 Enquiry")
                {
                    mail.Body = "Type 4 Enquiry \n\nContact Name: " + contacNameTextBox.Text.ToString() + "\nCompany Name: " + companyNameTextBox.Text.ToString() + "\nCompany Description: " + companyDescriptionTextBox.Text.ToString() + "\nWebsite: " + websiteLinksTextBox.Text + "\nPage that links back yo us: " + pageLinkingBackTextBox.Text.ToString() + "\nEmail: " + emailLinksTextBox.Text.ToString()+"\n\nMessage:\n\ n"+commentsTextBox.Text.ToString();

                }

                mail.Subject = subjectTextBox.Text.ToString();
                /* Some others implementations */


        }

// This is the posible method problem....


        protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (RadioButtonList1.SelectedValue == "Type 1 Enquiry")
            {
                nameTextBox.Visible = false;
                nameLabel.Visible = false;
                companyTextBox.Visible = false;
                companyLabel.Visible = false;
                phoneTextBox.Visible = false;
                phoneLabel.Visible = false;
                emailTextBox.Visible = true;
                emailLabel.Visible = true;
                webTextBox.Visible = false;
                websiteLabel.Visible = false;
                MultiView1.ActiveViewIndex = 0;
                subjectTextBox.Text = "Type 1 Enquiry";



            } if (RadioButtonList1.SelectedValue == "Type 2 Enquiry")
            {
                nameTextBox.Visible = true;
                nameLabel.Visible = true;
                companyTextBox.Visible = true;
                companyLabel.Visible = true;
                phoneTextBox.Visible = true;
                phoneLabel.Visible = true;
                emailTextBox.Visible = true;
                emailLabel.Visible = true;
                webTextBox.Visible = true;
                websiteLabel.Visible = true;
                MultiView1.ActiveViewIndex = 0;
                subjectTextBox.Text = "Type 2 Enquiry";


            } if (RadioButtonList1.SelectedValue == "Type 3 Enquiry")
            {
                nameTextBox.Visible = true;
                nameLabel.Visible = true;
                companyTextBox.Visible = false;
                companyLabel.Visible = false;
                phoneTextBox.Visible =false;
                phoneLabel.Visible = false;
                emailTextBox.Visible = true;
                emailLabel.Visible = true;
                webTextBox.Visible = false;
                websiteLabel.Visible = false;
                MultiView1.ActiveViewIndex = 0;
                subjectTextBox.Text = "Type 3 Enquiry";


            } if (RadioButtonList1.SelectedValue == "Type 4 Enquiry")
               {

                MultiView1.ActiveViewIndex = 1;

            }
        }
        protected void RadioButtonList1_Init(object sender, EventArgs e)
        {


        }
}


AND THIS IS THE ASPX


<%@ Page Language="C#" MasterPageFile="~/asd.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="somecontrol" Title="Some tittle" ValidateRequest="false" EnableSessionState="True" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <br />
    <center>

        <table id="table_big" align="center" cellpadding="0" cellspacing="0" language="javascript"
            onclick="return table_big_onclick()" style="border-right: black 1px solid; border-top: black 1px solid;
            border-left: black 1px solid; border-bottom: black 1px solid">
            <tr>
                <td class="table_big_title" colspan="2" style="height: 14px" align=center>

                        <span style="font-size: 18px">Contact Us</span></td>
            </tr>
            <tr>
                <td class="table_big_row">
                    <div align="justify" style="text-align: justify">
                        <br />
                        <br />
                        &nbsp;<table>
                            <tr>
                                <td style="width: 159px">
                                    <asp:Label ID="Label3" runat="server" Font-Bold="True" Font-Size="Small" Text="Select contact mode:"></asp:Label></td>
                                <td style="width: 248px">
                                    <asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="RadioButtonList1_SelectedI ndexChanged" CausesValidation="True" OnLoad="RadioButtonList1_SelectedIndexChanged" OnInit="RadioButtonList1_Init">
                                        <asp:ListItem Selected="True">Type 1 Enquiry</asp:ListItem>
                                        <asp:ListItem>Type 2 Enquiry</asp:ListItem>
                                        <asp:ListItem>Type 3 Enquiry</asp:ListItem>
                                        <asp:ListItem>Type 4 Enquiry</asp:ListItem>
                                    </asp:RadioButtonList>&nbsp;
                                    </td>
                            </tr>
                        </table>
                        &nbsp;
                        <asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0" >
                            <asp:View ID="View1" runat="server">
                                <table style="position: static">
                                    <tr>
                                        <td style="width: 100px">
                                        </td>
                                        <td style="width: 100px">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="width: 100px">
                                            <asp:Label ID="nameLabel" runat="server" Font-Bold="True" Font-Size="Small" ForeColor="Black"
                                                Style="position: static" Text="Name:"></asp:Label></td>
                                        <td style="width: 100px">
                                            <asp:TextBox ID="nameTextBox" runat="server" Style="position: static" Width="250px"></asp:TextBox></td>
                                    </tr>
                                    <tr>
                                        <td style="width: 100px">
                                            <asp:Label ID="companyLabel" runat="server" Font-Bold="True" Font-Size="Small" ForeColor="Black"
                                                Style="position: static" Text="Company:"></asp:Label></td>
                                        <td style="width: 100px">
                                            <asp:TextBox ID="companyTextBox" runat="server" Style="position: static" Width="250px"></asp:TextBox></td>
                                    </tr>
                                    <tr>
                                        <td style="width: 100px">
                                            <asp:Label ID="phoneLabel" runat="server" Font-Bold="True" Font-Size="Small" ForeColor="Black"
                                                Style="position: static" Text="Phone:"></asp:Label></td>
                                        <td style="width: 100px">
                                            <asp:TextBox ID="phoneTextBox" runat="server" Style="position: static" Width="250px"></asp:TextBox></td>
                                    </tr>
                                    <tr>
                                        <td style="width: 100px">
                                            <asp:Label ID="emailLabel" runat="server" Font-Bold="True" Font-Size="Small" ForeColor="Black"
                                                Style="position: static" Text="Email:"></asp:Label></td>
                                        <td style="width: 100px">
                                            <asp:TextBox ID="emailTextBox" runat="server" Style="position: static" Width="250px"></asp:TextBox></td>
                                    </tr>
                                    <tr>
                                        <td style="width: 100px">
                                            <asp:Label ID="websiteLabel" runat="server" Font-Bold="True" Font-Size="Small" ForeColor="Black"
                                                Style="position: static" Text="Website:"></asp:Label></td>
                                        <td style="width: 100px">
                                            <asp:TextBox ID="webTextBox" runat="server" Style="position: static" Width="250px"></asp:TextBox></td>
                                    </tr>
                                    <tr>
                                        <td style="width: 100px">
                                            <asp:Label ID="Label5" runat="server" Font-Bold="True" Font-Size="Small" ForeColor="Black"
                                                Style="position: static" Text="Subject:"></asp:Label></td>
                                        <td style="width: 100px">
                                            <asp:TextBox ID="subjectTextBox" runat="server" Style="position: static" Width="250px">General Enquiry</asp:TextBox></td>
                                    </tr>
                                    <tr>
                                        <td style="width: 100px; height: 10px;">
                                            <asp:Label ID="Label2" runat="server" Font-Bold="True" Font-Size="Small" ForeColor="Black"
                                                Style="position: static" Text="Message:" Width="78px"></asp:Label></td>
                                        <td style="width: 100px; height: 10px;">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="2">
                                            <asp:TextBox ID="NewsLetterTextBox" runat="server" Height="155px" Style="position: static"
                                                TextMode="MultiLine" ToolTip="Put newsletter here, you can include html tags."
                                                Width="541px"></asp:TextBox></td>
                                    </tr>
                                    <tr>
                                        <td colspan="2" align=center><asp:Button ID="Button3" runat="server" Text="Send" OnClick="Button1_Click" style="position: static" /></td>
                                    </tr>
                                </table>
                            </asp:View>
                            <asp:View ID="View2" runat="server">
                               <center><p>
Some text
                         </p>
                              </center>
                                <br />


                                <table style="position: static">
                                    <tr>
                                        <td style="width: 146px; height: 16px">
                                        </td>
                                        <td style="width: 100px; height: 16px">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="width: 146px">
                                            <asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Size="Small" ForeColor="Black"
                                                Style="position: static" Text="Contact Name:" Width="113px"></asp:Label></td>
                                        <td style="width: 100px">
                                            <asp:TextBox ID="contacNameTextBox" runat="server" Style="position: static" Width="250px"></asp:TextBox></td>
                                    </tr>
                                    <tr>
                                        <td style="width: 146px">
                                            <asp:Label ID="Label4" runat="server" Font-Bold="True" Font-Size="Small" ForeColor="Black"
                                                Style="position: static" Text="Company Name:" Width="124px"></asp:Label></td>
                                        <td style="width: 100px">
                                            <asp:TextBox ID="companyNameTextBox" runat="server" Style="position: static" Width="250px"></asp:TextBox></td>
                                    </tr>
                                    <tr>
                                        <td style="width: 146px">
                                            <asp:Label ID="Label6" runat="server" Font-Bold="True" Font-Size="Small" ForeColor="Black"
                                                Style="position: static" Text="Company Description:" Width="163px"></asp:Label></td>
                                        <td style="width: 100px">
                                            <asp:TextBox ID="companyDescriptionTextBox" runat="server" Style="position: static" Width="250px"></asp:TextBox></td>
                                    </tr>
                                    <tr>
                                        <td style="width: 146px">
                                            <asp:Label ID="Label8" runat="server" Font-Bold="True" Font-Size="Small" ForeColor="Black"
                                                Style="position: static" Text="Website:"></asp:Label></td>
                                        <td style="width: 100px">
                                            <asp:TextBox ID="websiteLinksTextBox" runat="server" Style="position: static" Width="250px"></asp:TextBox></td>
                                    </tr>
                                    <tr>
                                        <td style="width: 146px">
                                            <asp:Label ID="Label7" runat="server" Font-Bold="True" Font-Size="Small" ForeColor="Black"
                                                Style="position: static" Text="Page that links back to us:" Width="194px"></asp:Label>
                                        </td>
                                        <td style="width: 100px">
                                            <asp:TextBox ID="pageLinkingBackTextBox" runat="server" Style="position: static" Width="250px"></asp:TextBox></td>
                                    </tr>
                                    <tr>
                                        <td style="width: 146px">
                                            <asp:Label ID="Label9" runat="server" Font-Bold="True" Font-Size="Small" ForeColor="Black"
                                                Style="position: static" Text="Email:"></asp:Label></td>
                                        <td style="width: 100px">
                                            <asp:TextBox ID="emailLinksTextBox" runat="server" Style="position: static" Width="250px"></asp:TextBox></td>
                                    </tr>
                                    <tr>
                                        <td style="width: 146px">
                                            <asp:Label ID="Label10" runat="server" Font-Bold="True" Font-Size="Small" ForeColor="Black"
                                                Style="position: static" Text="Comments:" Width="78px"></asp:Label></td>
                                        <td style="width: 100px">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="2">
                                            <asp:TextBox ID="commentsTextBox" runat="server" Height="155px" Style="position: static"
                                                TextMode="MultiLine" ToolTip="Put newsletter here, you can include html tags."
                                                Width="541px"></asp:TextBox></td>
                                    </tr>
                                    <tr>
                                        <td colspan="2" align=center style="height: 15px"><asp:Button ID="Button2" runat="server" Text="Send" OnClick="Button1_Click" style="position: static" /></td>
                                    </tr>
                                </table>
                            </asp:View>
                        </asp:MultiView>
                                    <center>
                                        &nbsp;</center><br />
                        <br />
                    </div>
                    </td>
            </tr>
        </table>
    </center>
    <center>
        &nbsp;</center>
</asp:Content>

Also tried now with a application variable setting on every change so i set the selected value on load, it just works worst!...

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
F5 (Refresh) adds a new record after postback krainov BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 November 20th, 2007 10:10 AM
Custom Postback and Gridview refresh wirerider ASP.NET 2.0 Basics 5 February 28th, 2006 04:33 PM
Updating DataGrid without PostBack/Refresh Baby_programmer ASP.NET 1.0 and 1.1 Professional 13 April 11th, 2005 04:47 AM
Refresh DataGrid without PostBack Baby_programmer Classic ASP XML 1 April 2nd, 2005 04:22 AM
Refresh a combobox without postback Eddy ASP.NET 1.x and 2.0 Application Design 1 March 10th, 2004 12:34 AM



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


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