I am using ASP.NET and C# couple text boxes to calculate results entered. Textbox2 has a value entered and on button click Textbox1 gets populated. This works fine the first time I enter the value. But the second time I change the value in Textbox2, I see that the value is being assigned to Textbox1 while debugging on Button click, but doesn't show up on the screen. I have many other controls and a master page. The textboxes are within an update panel.
Can someone help me what's going on?
Here is the code:
<asp:TextBox ID="Textbox1" runat="server" Width="150px" TabIndex="6" MaxLength="8"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ControlToValidate="TextBox1" ErrorMessage="*"></asp:RequiredFieldValidator>
<asp:TextBox runat="server" ID="Textbox2" Width="150px" Visible="false"></asp:TextBox> 
<asp:ImageButton runat="server" ID="imgCalcAdjRate" ImageUrl="~/Resource/Images/calrate_0.bmp" onmouseout="this.src='../Resource/Images/calrate_0.bmp'" onmouseover="this.src='../Resource/Images/calrate_1.bmp'" Height="25px" Width="25px" Visible="false" onclick="imgCalcAdjRate_Click" />
Check the postback in the page_load function.
if(!Page.IsPostBack) {
}
I think you are loosing information on post back. The data is changed, but it get reset on post back.
Related
I have some textboxes in my asp.net site and also some field validators for that textboxes.
Now I've added a "back" button to go back to another page, but I can't press the button when not every field is filled.
Do you have any sugestions how to solve this problem?
aspx:
<asp:TextBox ID="tbInformation" runat="server" TextMode="MultiLine" Height="130px" Width="550px" />
<asp:RequiredFieldValidator runat="server" ID="rfvInformation" ControlToValidate="tbInformation" ErrorMessage="*Required*" />
I am using ASP.NET and C# couple text boxes to calculate results entered. Textbox2 has a value entered and on button click Textbox1 gets populated. This works fine the first time I enter the value. But the second time I change the value in Textbox2, I see that the value is being assigned to Textbox1 while debugging on Button click, but doesn't show up on the screen. I have many other controls and a master page. The textboxes are within an update panel.
Can someone help me what's going on?
Here is the code:
<asp:TextBox ID="Textbox1" runat="server" Width="150px" TabIndex="6" MaxLength="8"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ControlToValidate="TextBox1" ErrorMessage="*"></asp:RequiredFieldValidator>
<asp:TextBox runat="server" ID="Textbox2" Width="150px" Visible="false"></asp:TextBox> 
<asp:ImageButton runat="server" ID="imgCalcAdjRate" ImageUrl="~/Resource/Images/calrate_0.bmp" onmouseout="this.src='../Resource/Images/calrate_0.bmp'" onmouseover="this.src='../Resource/Images/calrate_1.bmp'" Height="25px" Width="25px" Visible="false" onclick="imgCalcAdjRate_Click" />
Check the postback in the page_load function.
if(!Page.IsPostBack) {
}
I think you are loosing information on post back. The data is changed, but it get reset on post back.
I am using calendar extender to create a popup textbox when a user click in a specific textboxk:
<asp:Label ID="searchDateFromLabel" runat="server" Text="From:"></asp:Label>
<asp:TextBox ID="searchDateFrom" runat="server" ></asp:TextBox>
<ajaxToolkit:CalendarExtender ID="fromCalendarExtender" TargetControlID="searchDateFrom" runat="server">
</ajaxToolkit:CalendarExtender>
<asp:Label ID="searchDateToLabel" runat="server" Text="To:"></asp:Label>
<asp:TextBox ID="searchDateTo" runat="server"></asp:TextBox>
<ajaxToolkit:CalendarExtender ID="toCalendarExtender" TargetControlID="searchDateTo" runat="server">
</ajaxToolkit:CalendarExtender>
Additionally, I populate the textboxes with default dates on page load:
fromCalendarExtender.SelectedDate = DateTime.Today.AddDays(-30);
toCalendarExtender.SelectedDate = DateTime.Now;
The issue I am having is that when a user clicks a textbox that is populated, it won't let them choose another date (other than the one the texbox was populated with) unless they first delete the text currently in the box.
How do I allow them to select any date?
Set PopupControlID to the TextBox you are trying use to select the date. It should then force the data-selector to pop up whenever the user gives focus to the TextBox.
I have the following textBox -
<asp:TextBox ID="TextBox1" runat="server" AutoPostBack="true"></asp:TextBox>
<asp:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server"
MinimumPrefixLength="1" ServiceMethod="PRETURN" ServicePath="WebService1.asmx"
TargetControlID="TextBox1"> </asp:AutoCompleteExtender>
When a user types into TextBox1 this sends a request to WebService1.asmx and calls the PRETURN service method. So as a user is typing the textBox brings a drop down list of strings that start with the letters the user is typing.
I now have the following DataList -
<asp:DataList runat="server" ID="pTextBox" >
<ItemTemplate>
<asp:CheckBox ID="CheckBoxPN" runat="server" Checked='false' OnCheckedChanged="CheckBoxPN_CheckedChanged" AutoPostBack="true" />
<asp:TextBox ID="profileTextBox" runat="server" Text='<%# Container.DataItem.ToString() %>'></asp:TextBox>
</ItemTemplate>
</asp:DataList>
Where on Page_Load -
WebService1 ws = new WebService1();
pTextBox.DataSource = ws.Method();
pTextBox.DataBind();
My problem is I want to combine the functionality of the textBox with the DataList. So that when a user types into the textBox, instead of the textBox having a dropdown list, the rows in the DataList are updated. So for instance, if Text in the profileTextBox did not contain the prefix text in TextBox1 when the user was typing, it would disappear. Leaving the user with a list of rows relevant to their search. How can I achieve this?
Others have done something similar to the GridView control, using JQuery to show/hide rows depending on the filter criteria. One solution, which should be easily adaptable to the DataList, is available here.
I've created FormView let user enter the data to save into database. And i need to disable one of the textbox and automatic set the GUID to the textbox. how can i do that?
<InsertItemTemplate>
RouteGUID:
<asp:TextBox ID="RouteGUIDTextBox" runat="server"
Text='<%# Bind("RouteGUID") %>' Enabled="False" />
<br />
you should Bind the FormView control on Page_Load..or should call the Formview.DataBind() method on page_load...as i can't see your full code, so said this as an assumption.