Ordered Dictionary Loses Value
Oct 3, 2011
I am building a "query tool" so I am creating queries on the fly using DropDownLists (DDLs) to select table and field names. I have selected a Ordered dictionary to retain the association between field name and data type which I need to build my query string, to insert # for dates and quotes for strings. (I don't know that I could parameterize this process without creating a virtual nightmare of complexity) I am building the content of the field DDL in the onChange event of the table DDL using a function DDL_TableNames_SelectedIndexChanged() that returns a DataTable of selected fieldnames. Because I ran into so much trouble trying to include the field type in this process, I separated the two and am now using the ordered dictionary to remember what data type each of the selected fields is.
The problem lies in the fact that the ordered dictionary loses its value in subsequent Postback operations. So it populates on Postback, but resets after that since when I try to use the contents of the ordered dictionary it has no values.
Code:
'Dim global OrderedDictionary variable
Dim dicFieldNameType As New OrderedDictionary()
Protected Sub _DDL_TableNames_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DDL_TableNames.SelectedIndexChanged
Dim vTableName As String
[code]...
View 1 Replies
Similar Messages:
Dec 23, 2010
I have a class that maintains a static dictionary of cached lookup results from my domain controller - users' given names and e-mails.My code looks something like:
private static Dictionary<string, string> emailCache = new Dictionary<string, string>();
protected string GetUserEmail(string accountName)
{
if (emailCache.ContainsKey(accountName))
{
return(emailCache[accountName]);
}
lock(/* something */)
{
if (emailCache.ContainsKey(accountName))
[code]...
View 6 Replies
Jul 20, 2010
I have a upload section on a user control
<div class="AttachQuote"><fieldset>
<legend>Quote(s)</legend>
<asp:Button ID="btnAttachQuote" UseSubmitBehavior="false" Text="Attach Quote" runat="server" />
<ol id="olUploadedFiles" style="list-style-type: decimal; padding-left: 30px;">
</ol></fieldset></div>
the btnAttachQuote is defined as
protected global::System.Web.UI.WebControls.Button btnAttachQuote;
can i do something simular to olUploadedFiles? there are alot of list options in webcontrols and i'm unsure how to use them. I would like to use a for loop to populate olUploadedFiles from a string array in my .cs. something like ...
int i = 0;
while (files[i].Length !=0)
{
olUploadedFiles.add (files[i]);//i'll substring the file names out
i++;
}
I'm using the same control for both the form submit and the status page(label only mode). I can load the rest of the info i just can't populate the dropdown from the codebehind.
View 3 Replies
Jan 22, 2013
what's the steps for making invoices in a eshop? need I make a saperate table for invoices? Or can I use products and orders and orderlines tables to make invoice?
I think I can do it by shoing orderId, username,orderstatus, total price,... in a gridview and shoing ordered products name,quantity, price in a child gridview in grdview above and print above information.
Is it right way or not?
is there any better way? and for example for 50 orders in a day how can I print 50 Invoice in seperate a4 pager?
View 1 Replies
Mar 5, 2010
I want to create a Dictionary... where i can get Dictionary database or World lists (english to english , english to hindi)
View 1 Replies
Aug 25, 2010
I have a few tables, Listings, ListingImages and a few others related to Listings. ListingImages is related to Listings so that you can have many ListingImages per Listing.
When I query this table I do;
[code].....
Now this is fine. However, I now want to sort the ListingImages independently within each Listing (by an ImageOrder column I have in that table).
How can I do this and pass all my Includes(...). Would it be bad form to sort the ListingImages within the View as this solution seems to work?
View 1 Replies
May 3, 2010
I have a set of radio buttons for "yes" and "no" values which have a name="choice". "yes" is checked by default. They're both runat="server". I read the choice on postback like below. It works perfectly fine as long as the validation doesn't fail. For example, if I select "no" and validation fails on postback, I still see "no" selected. But if I submit the form after correcting everything, the value read is "yes" on server side! Is this a bug in .net, and if so, how do i fix this?
foreach (string key in Request.Form.AllKeys)
{
if (key.EndsWith("choice"))
return Request.Form[key] == "yes";
}
View 1 Replies
Apr 13, 2010
I'm having trouble with a simple radio set of two radio buttons (I don't want to use a RadioButtonList [RBL] because RBL doesn't allow child controls, and in my case, if you select one option, I want to enable a textbox next to the button; yes you could hack this with jQuery to move the textbox, but that's dirty!). I would check one, submit the form (either explicitly or through AutoPostBack), and the CheckedChanged event would never fire. When the page was reloaded, both buttons would be unchecked, regardless of their initial state on non-postback load or the state before form submission.
form id="form1" runat="server" enableviewstate="true">
<div>
<asp:RadioButton ID="foo" Text="foo" runat="server" AutoPostBack="true" OnCheckedChanged="rbChanged" Checked="true" GroupName="foobar" EnableViewState="true" />
<asp:RadioButton ID="bar" Text="bar" runat="server" AutoPostBack="true" GroupName="foobar"
OnCheckedChanged="rbChanged" Checked="false" EnableViewState="true" />
[code]...
View 2 Replies
Sep 17, 2010
I'm using tablesorter in an asp:GridView and works fine but this been bother me for some timeEvery time there is a button action (firing up a call to the server, refreshing the page), table sorter loses the headers as you can see by the 2 images below:before refresh:after refresh:Does anyone have an idea of if this might be a bug, or something on my end just for the behavior of it? Maybe someone already crossed this problem before
View 2 Replies
Apr 8, 2010
I have been making use of the WCF Authentication Service in ASP.Net but I have found that whenever you navigate all session, user, login data is lost.I have tested using the Standard ASP.Net Login page and mechanism and everything works fine.Why is nothing persisting from one page to another?
View 1 Replies
Oct 26, 2010
If I have a list of radiobuttons like this:
[Code]....
, when submitting the form and return the untyped View again, the selection is lost. What is the best practise to overcome this in MVC?
My submit-action looks like this as I am also passing an uploaded file...
[Code]....
View 2 Replies
Sep 11, 2010
I'm having a little problem with my file uploading. Does anybody know how to maintain the value in the FileUpload control between server posts?
I have a form which, among other things, uploads a file. I am using an ileUpload control (created dynamically) to let a user browse their PC for a file and then using the SaveAs method to upload the file to the server.When I'm selecting a file and Click on Next button for processing then selected file is lost.
Same is happening with me with HtmlTextArea (dynamically generated) , the problem was that I was not again re-initializing the controls after postback. What I did is re-initialized it in Init method of placeholder (as I have created/placed all dynamic controls in placeholder ).
But this thing is not working for fileupload control. I found solution in one of the forum is that "use hiddenField Control to transfer the selected file from the client to server"but this mechanism will only help to retain the name of file
in a hidden variable and the FileUpload1.PostedFile.SaveAs(filename) will not work bcz of absense of object (fileupload1).
here is code:
[Code]....
I have done almost the same in different test project , it works . I dont know whats wrong?
[Code]....
How to correct this?
View 8 Replies
Feb 23, 2011
I have a webform that the user inputs a date via a javascript popup calander, then it auto populates a textbox with 45 days after the inputed date.
My question is is there a way to have a postback once the input date loses focus. Here is my page.
ASPX
[Code]....
C#
[Code]....
View 5 Replies
Aug 4, 2010
I have a web-site application that uses a reportviewer control. One of the parameters in a report that gets opened via this control is of a datetime data type and comes with a built-in calendar control to choose the date. Here is my problem: when I run this reports as a part of a SSRS project the calendar allows to choose a month (it shows a list of months when you click on a month name in the calendar header) and a year (it shows an up-down arrow set when you click on a year), while when this report runs in the application this functionality is lost.
Our users are used to this functionality and expect to have it in a new application. How can I change properties of a calendar control in the parameter area of a reportviewer?
[URL] article says:
"The ReportViewer Web server control includes an HTTP handler that is used to ... provide a calendar control used to select dates for a report parameter... "
Are there different versions of HTTP handler that would allow regulate the calendar functionality?
View 2 Replies
Oct 18, 2010
There is button(btnOpen) and a textbox (txtResult) in the page.
Once I clicked on btnOpen, a modal dialog will appear, displaying TextBox1 and Button1.
The user is required to type something in TextBox1 and I want to pass the TextBox1.Text into my database but when I try to do that, the value actually = "", which is gone.
So I created this test program to illustrate by passing the value into a txtResult.
Can anyone guide me on getting the TextBox1.Text value?
Besides that, is there anyone to tell more about what does this lines of code do?
[Code]....
The aspx code:
[Code]....
the Code Behind .cs :
[Code]....
View 2 Replies
Apr 7, 2010
Ive added checkbox to each gridview row like this:
[Code]....
I grab value of selected checkboxes like this:
[Code]....
So. It works fine, but when i change page of gridview, previous page loses selection and set all checkboxes to false.
Probably this is because paging causes postback, but still, is there an easy solution to rewrite my code, so it will work with paging?
Maybe theres a way to disable postback on page change?
View 8 Replies
Jun 22, 2010
Google usually solves my problems for me, but this one has me stumped. I have a page with the following code, in which lstPayments is a listview control:
public partial class frmPerson : System.Web.UI.Page
{
protected bool paymentWarning = false;
protected void Page_PreRender(object sender, EventArgs e)
{
if (paymentWarning == true)
{
string alertText = "alert('Hello World');";
if (!ClientScript.IsStartupScriptRegistered("Alerter"))
ClientScript.RegisterStartupScript(this.GetType(), "Alerter", alertText, true);
}
}
protected void lstPayments_ItemInserted(object sender, ListViewInsertedEventArgs e)
{
paymentWarning = true;
}
}
As you can see, I'm trying to get an alert box displayed after a new payment is entered. As I expect, lstPayments_ItemInserted is executed first, and paymentWarning is duly set to true. However, when Page_PreRender subsequently executes, paymentWarning has been re-initialised: it's false again!
The only way I can get the class-level variable paymentWarning to retain it's value between the two event handlers is to declare it static, which I don't want to do for obvious reasons. There must be something I am failing to understand about how class-level variables work in aspx pages.
View 4 Replies
Mar 7, 2012
When I click the button the values of my label and texbox become null. Here's my code not working loses values when button is click
Code:
protected void Page_Load(object sender, EventArgs e)
{
string bid_id = Request.QueryString["bid_id"];
Label1.Visible = false;
if (!IsPostBack)
[Code] ....
Code:
protected void placeBid_texbox_Click(object sender, EventArgs e)
{
if (User.Identity.IsAuthenticated)
{
SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["LocalSqlServer"].ConnectionString);
[Code] .....
View 15 Replies
Jan 28, 2010
I am creating a control that inherits from the RadioButton, so that I can set the GroupName property manually. Everything is working okay apart from the fact that when the page posts back, the RadioButton becomes unchecked if it has previously been checked. This is the first time I've tried inheriting from controls, so must be doing something really silly. I would welcome anyone helping me to improve my code so that the control's Checked value persists through postbacks. I am causing a postback using a button, not the actual RadioButton itself, if that makes any difference. Here is my code:
[Code]....
View 13 Replies
Feb 1, 2011
I have the following simple code:
[Code]....
So when i select "Yes" from the first drop down, the "hiddenDetail" label becomes visible and when i select "No" from q1 the "hiddenDetail" label becomes invisible.The problem is that because i am using AutoPostBack when you select "No" the "hiddenDetail" loses its children (i.e. the label inside it) which is obvious why but i am wondering, is there anyway i can make the "hiddenDetail" invisible (sort of like display:none in style) in VB without losing its children. Or is my only option to work with this in
View 9 Replies
Jul 28, 2010
I have a custom control in an aspx page that has a property named Size
public int Size
{
get { return Convert.ToInt32(ViewState["CreativeSize"]); }
set { ViewState["CreativeSize"] = value; }
}
This property is set in the aspx page to a value lets say 500 during a postback called by a Button control that is in the page (not in the custom control).
I also have a button inside the custom control that raises a postback like this
protected void btnUpload_Click(object sender, EventArgs e)
{
if (fuBannerfile.HasFile)
if (fuBannerfile.FileContent.Length / 1024 > this.Size)
;//code here not important
}
When this event is called the "this.Size" property is 0. I also noticed during debugging that during Page_Load of the page, if i access the property like this:
int size = customControlId.Size;
the property is set to 500. But after that when the debugger reaches the event inside the control the property is 0.
View 1 Replies
Jun 2, 2010
I have a web part which is going to be a part of pair of connected web parts. For simplicity, I am just describing the consumer web part.
This web part has 10 link buttons on it. And they are rendered in the Render method instead ofCreateChildControls as this webpart will be receiving values based on input from the provider web part. Each Link Button has a text which is decided dynamically based on the input from provider web part.
When I click on any of the Link Buttons, the event handler is triggered but the text on the Link Button shows up as the one set inCreateChildControls. When I trace the code, I see that the CreateChildControls gets called before the event handler (and i think that resets my Link Buttons). How do I get the event handler to show me the dynamic text instead?
Here is the code...
public class consWebPart : Microsoft.SharePoint.WebPartPages.WebPart
{
private bool _error = false;
private LinkButton[] lkDocument = null;
[Code]....
View 3 Replies
May 7, 2015
radiobuttonlist Value is not saved when saving on where the problem is?
<form id="form1" runat="server"> <div> <asp:RadioButtonList ID="rblShippers" runat="server"> </asp:RadioButtonList> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /> </div> </form>
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Data;using System.Data.SqlClient;public partial class _Default : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) {
string strConnString = "data source=.;initial catalog=saeed;integrated security=true"; using (SqlConnection con = new SqlConnection(strConnString)) {
[CODE]...
View 1 Replies
Apr 5, 2010
I try to postback my page to the server using ctrl+Enter sequence.Without UpdatePanel it works well, but it works only two times inside updatepanel and then my control loses the focus. So I have some questions:
1. Why my control loses the focus if it is located inside updatepanel?
2. What is the best way to use ctrl+Enter sequence to post the page to the server?
Here is my code:
[Code]....
View 4 Replies
May 3, 2010
I have the following setup:
[URL]
[URL]
Each virtual directory is configured on IIS6.0 as an application with own AppPool.
When redirecting authenticated user from dir1 to dir2 using response.redirect I lose authentication information for the user and the user is being redirected to the login page. This issue was not coming up with each app (dir1 and dir2) were configured under subdomain, ex: [URL]
I have resolved the issue by adding a machine key to the machine.config file.
View 2 Replies