473,500 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP.NET Weird Event Behaviour

7 New Member
Hey Guys,
I'm experiencing some really odd behavior from the simple onclick event attached to one of my buttons.

I have a user control, with three buttons Save, Edit and Create. They enable different asp.net controls and that's all working fine. However when I click my save button after I have edited some data, the new data is not loaded in with the onclick event of the save button.
So to speak, it just reposts all the old values and stores these in my database again and the new values vanish.

ASP code
Expand|Select|Wrap|Line Numbers
  1. <table width="300px" cellpadding="5"  cellspacing="0">
  2.     <tr>
  3.         <td>
  4.             Navn:
  5.         </td>
  6.         <td>
  7.             <asp:TextBox ID="txtSolutionName" runat="server" CssClass="TextBox200" />
  8.         </td>
  9.     </tr>
  10.     <tr>
  11.         <td width="100px">
  12.             Kunde:
  13.         </td>
  14.         <td>
  15.             <radC:RadComboBox          
  16.              ID="rcbCustomers"
  17.              runat="server"
  18.              Height="150px"
  19.              Width="200px"
  20.              MarkFirstMatch="true"
  21.              Skin="WindowsXP"
  22.              HighlightTemplatedItems="true"
  23.              Style="width:200px !important;">
  24.                  <Items>
  25.                      <radC:RadComboBoxItem Text="---Vælg---" Value="0"/>
  26.                      <radC:RadComboBoxItem Text="Baltic Workforce" Value="1" />
  27.                      <radC:RadComboBoxItem Text="AV Forlaget" Value="2" />
  28.                      <radC:RadComboBoxItem Text="Finn Nygaard" Value="3" />
  29.                      <radC:RadComboBoxItem Text="Merrild" Value="4" />
  30.                      <radC:RadComboBoxItem Text="FC Fyn" Value="5" />
  31.                      <radC:RadComboBoxItem Text="Mitsubishi" Value="6" />
  32.                  </Items>
  33.             </radC:RadComboBox>
  34.         </td>
  35.     </tr>
  36.     <tr>
  37.         <td width="100px">
  38.             Skabelon:
  39.         </td>
  40.         <td>
  41.             <radC:RadComboBox          
  42.              ID="rcbTemplates"
  43.              runat="server"
  44.              Height="150px"
  45.              Width="200px"
  46.              MarkFirstMatch="true"
  47.              Skin="WindowsXP"
  48.              HighlightTemplatedItems="true"
  49.              Style="width:200px !important;">
  50.                  <Items>
  51.                      <radC:RadComboBoxItem Text="---Vælg---" Value="0"/>
  52.                      <radC:RadComboBoxItem Text="Totalløsning" Value="1"/>
  53.                      <radC:RadComboBoxItem Text="Billedbank" Value="2"/>
  54.                      <radC:RadComboBoxItem Text="Ekatalog" Value="3"/>
  55.                      <radC:RadComboBoxItem Text="Ingen" Value="4"/>
  56.                  </Items>
  57.             </radC:RadComboBox>
  58.         </td>
  59.     </tr>
  60.     <tr>
  61.         <td>&nbsp;</td>
  62.         <td align="right">
  63.             <asp:Button ID="btnCreateNewSolution" runat="server" Text="Opret" CssClass="Button" OnClick="btnCreateNewSolution_Click" />
  64.             <asp:Button ID="btnEditSolution" runat="server" Text="Redigér" CssClass="Button" OnClick="btnEditSolution_Click" />
  65.             <asp:Button ID="btnSaveSolution" runat="server" Text="Gem" CssClass="Button" OnClick="btnSaveSolution_Click" />
  66.         </td>
  67.     </tr>
  68. </table>
  69.  
Code Behind
Expand|Select|Wrap|Line Numbers
  1. public partial class ucCreateSolution : System.Web.UI.UserControl
  2.     {
  3.  
  4.         protected void btnSaveSolution_Click(object sender, EventArgs e)
  5.         {
  6.             UpdateSolution(Convert.ToInt32(Request.QueryString["SolutionID"]));
  7.             txtSolutionName.Enabled = false;
  8.             rcbCustomers.Enabled = false;
  9.             rcbTemplates.Enabled = false;
  10.             btnCreateNewSolution.Visible = false;
  11.             btnEditSolution.Visible = true;
  12.             btnSaveSolution.Visible = false;
  13.         }    
  14.         private void UpdateSolution(int solutionID)
  15.         {
  16.             SolutionHandler.UpdateSolution(solutionID, txtSolutionName.Text, 0); //This is where the values are still the old ones, the txtSolutionName.Text takes the old value.
  17.         }
  18.     }
  19.  
Any help is greatly appreciated.

Thanks in advance,
--Michael
Apr 8 '08 #1
2 1413
harshmaul
490 Recognized Expert Contributor
It is probably a dotnet post back problem.

ensure that you're loading the data in to the boxes on page load and in an

if(!IsPostBack)

condition

example...

Expand|Select|Wrap|Line Numbers
  1. if(!IsPostBack){
  2. txtTextBox1.Text="hello world";
  3. }
Apr 8 '08 #2
ShahbazAshraf
36 New Member
1) May be your control is updating the value of "txtSolutionName" control
2) In asp.net Page_Load event is fired on each post back and then the particular event is fire so in your scenario may be u have done some work which update the value of txtSolutionName.Text in Page_Load event.
Apr 8 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

10
2034
by: Chris Mantoulidis | last post by:
I see some really weird output from this program (compiled with GCC 3.3.2 under Linux). #include <iostream> using namespace std; int main() { char *s; s = "test1"; cout << "s = " << s << "...
8
1422
by: Deano | last post by:
Here's the code; Private Sub txtTeachName_LostFocus() If IsNull(Me.txtName) Then 'line A Forms!frmMainform!frmSubform.Locked = True GoTo Exit_txtName Else 'line B...
1
2251
by: fd123456 | last post by:
The TextBoxes in ASP have a weird behaviour when it comes to handling carriage returns. You can try this : Create a Webform. On it, place a textbox, set it's TextMode property to MultiLine....
1
1680
by: hecsan07 | last post by:
I am trying to perform site login using values from a cookie, but for some weird reason the cookie is being destroyed after the browser window is closed. I checked the browser settings for the...
10
3980
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
9
1272
by: ZorpiedoMan | last post by:
This is so weird, and I cannot even isolate the cause enough to give any clues as to how to reproduce the error, so this is probably a real shot in the dark... BUT, has anyone ever run into a...
4
1142
by: Kevin O'Donovan | last post by:
Hi, Is anyone else experiencing this, or better yet, have a fix for it: We have VS.Net 2003 from the MSDN Universal subscription installed on 3 workstations. We have about 10 or so projects...
3
1187
by: Bryan | last post by:
I have a listbox that the user is able to add items to through and SQL statement that is run on the NotInList event. At the end of the event, I set Response = acDataErrAdded, telling access that...
2
2504
by: ian | last post by:
Hi, I've got the weirdest garbage collection problem - I'd appreciate any advice you've got. 1. A class 'X' in a system I'm working on contains a reference to an XmlDocument, populated via...
0
1810
by: Tom Edelbrok | last post by:
I'm using VS 2005 to develop an intranet asp.net web application and I get a weird situation. If I start out with any ASPX page that contains an ImageButton control followed by a TextBox control,...
0
7018
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7182
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7232
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6906
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7397
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4923
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3106
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
672
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
316
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.