Retain IEnumerable<T> Value During Postback?

Mar 17, 2010

I have an IEnumerable< T> which is declared on the page like this:IEnumerable< Person> person;When the page postsback, the person list is null. How can I retain the values of person list without declaring it as static? Sr. devs in my company say that you should not declare the list as static.

View 2 Replies


Similar Messages:

C# - How To Retain Password Field Value On PostBack

Aug 19, 2010

Right now I have an asp:Wizard with 3 Steps.

Create User
Form to Email
Summary of Fields

When the finish button is clicked on the third step I would like to Create the user and send the form. I have the logic for this written but the only problem I have is the when the next button is pressed on a wizard, a PostBack occurs and my password field:

<asp:TextBox ID="txtPassword" TextMode="Password" Width="70%" runat="server" />

Does not retain its value.

View 2 Replies

Web Forms :: Retain Value In FileUpload Control After Postback?

Mar 27, 2010

I have seen many posts here regarding this, but none with a successful solution.I m using a asp.net fileupload control & not the html one.I have various controls on the page, & on a listbox control, listitem selection, page postbacks.So before it, if i had selected a file for upload & page poastbacks, the the file goes off.Now on postback, I have got the filename in a hidden field, but since the Fileupload control doesnt have any setter methods, not able to get how to set the hidden field value & how to set it...

View 2 Replies

Web Forms :: How To Retain Scroll Position On Postback

Jul 23, 2010

How can we retain Panel scroll position on postback without using any cookies.

View 6 Replies

AJAX :: How To Retain Focus After Postback (updatepanels)

May 14, 2010

We currently have a page with several user controls (8 of them) and when a control that is contained in an updatepanel initiates a postback the focus is not retained. In some cases, it looks like the focus is sent to the top of the page, and in other cases the focus looks like it is sent to the control with the TabIndex=1.

I have tried 3 different solutions and they all end up with the same result.

The first two were from article:
[URL]

Solution 1: At the end of the server event executed in postback, add:

[Code]....

The article says both of those solutions worked, but for us, neither of them did.[Code]....
ASPX.CS

[Code]....

[Code]....

In all 3 scenarios the control we want to have the focus gets the focus for a split second and then the focus is cleared (set to the top of page, or TabIndex=1).

View 3 Replies

AJAX :: Retain FileUpload Control Value On PostBack

May 7, 2015

I have a grid view which is costomized.I upload a image in this,when i click edit button then give error (Specified cast is not valid.)

<td align="center" rowspan="11" style="width: 130px" valign="top">
<asp:FileUpload ID="FileUpload4" runat="server" Width="100px"
Enabled='<%# bind("imagePath") %>' />
<asp:Label ID="lblimage" runat="server" Text='<%# Bind("imagepath") %>'
Visible="False"></asp:Label>
</td>

View 1 Replies

Web Forms :: FileUpload Control Does Not Retain Value On Postback

Nov 15, 2011

IĀ have a ASP.Net FileUpload control in my page. Once the File is uploaded I want to display the path in FileUpload control

View 1 Replies

Web Forms :: How To Retain Array Values Across PostBack

Feb 18, 2014

I am using string builder class to store the dropdown selected values .. I am doing this on the selected index change event .. The problem is the previous value does not retainĀ ..

sb.Append(degreedropdown.SelectedValue+"-");
string nums = sb.ToString();
string pattern = "-";
string[] substrings = Regex.Split(nums, pattern);
arraylength = substrings.Length;

View 1 Replies

Javascript - How To Retain Script Block On A Partial Postback

Nov 20, 2010

This is a problem I'm facing in a webapp I'm currently working on. So instead of cluttering the question with unrelated code, I recreated the problem in an isolated, simplified webapp that only demonstrates this issue.

I have a web user control with just this as its content:

<% if (ShowAlertScript)
{ %>
<script type="text/javascript">
function AlertMe()
{
alert('Hello World!');
}
</script>
<% } %>
<input type="button" onclick="AlertMe()" value="Say Hello" />

And its codebehind has nothing more than the boolean definition of ShowAlertScript. This represents a control I have in the big webapp that has two modes: input mode, and display mode. When in input mode, it has a large javascript block that is only useful then; it does some cool stuff to help the user input the info.The way this control is laid out in the big picture is as follows:

<asp:ScriptManager runat="server" />
<asp:UpdatePanel runat="server">
<ContentTemplate>
<asp:MultiView ActiveViewIndex="0" runat="server" ID="mvw">
<asp:View runat="server">
<asp:Button runat="server" ID="btnSwitch"
OnClick="btnSwitch_Click" Text="Switch" />
</asp:View>
<asp:View runat="server">
<uc:MyInputControl runat="server" ID="micInput" ShowAlertScript="true" />
</asp:View>
</asp:MultiView>
</ContentTemplate>
</asp:UpdatePanel>

When you click btnSwitch, it simply switches to the second view with the user control. Notice how I have the ShowAlertScript already initialized to true. The potential output is that since I'm "showing the alert script" within the user control, the AlertMe() function will execute when you click the input-button element, because it's written out according to the inline if statement.

If you run this code I gave you so far as is, it will not work. The browser will say it can't see the AlertMe() function; it's undefined as far as it knows. But if you take out the UpdatePanel (or disable the ScriptManager's partial rendering), it will work just fine on a full postback when you click btnSwitch.

I want it to work on a partial postback, because this whole thing is a small piece compared to the rest of the page, and I don't want to do a full postback every time they switch views. Apparently, the ScriptManager doesn't even bother re-rendering the ascx file for possible changes. Either the ScriptManager is not smart enough, or there is an option I'm missing to let it render the <script> so I can invoke its methods on the client side. A potential answer someone might suggest is "why don't you take out the javascript, put it in its own .js file, and have the page reference it so it's available to the control?"
That won't really work with me, because the script block does some initialization and modification that pertain to that single control instance, not to all others on the page.

In turn, you might also be concerned that if I have more than one instance of the control, I end up with copies of the same script. Not really; there will only be ONE input mode of this control in a page at any given time, it's just that I have those two modes in two separate views and I let the user switch between them.

View 2 Replies

Forms Data Controls :: How To Retain Values During Postback

Nov 22, 2010

I am having an aspnet panel in my aspx file.There is an ultraweb tab placed inside this.also I am having a button outside this panel.Within the tab I have a textbox whose readonly property is

set to "true".Whenever I click the button a javascript function is called .On clicking 'OK' in the popup ,the textbox values are lost.Is there a way to retain these values?

View 5 Replies

Data Controls :: Retain Expanded GridViews On PostBack

Jul 24, 2013

I have the example working but I added a Select Command to the Detail grid for the purpose of selecting a detail record which will redirect to another page. The problem is that when the Select command is clicked the expanded detail grid collapses as if I had clicked the minus. The page and codebehind are:

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Search1.aspx.vb" Inherits="iDCA.Search1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>

[code]...

View 1 Replies

JQuery :: Tools Tabs Doesn't Retain Tab Index On Postback

Sep 6, 2010

The graphic designer of a project I'm building a web site for chose jquery.tools [URL] for a tabs tool in the site. Unfortunately it seems that the tool doesn't behave properly on a postback in IE7 or IE8 (it does behave properly in FireFox, Chrome and Safari). Does anyone have experience using the jquery.tools with asp.net? and know how to retain the tab index on a postback? I've tried a lot of things and can't get it to work. The code i'm using now is as follows:

$("ul.tabsScenario").tabs("div.panes > div");
var tabIndex = $('#ctl00_ContentPlaceHolder1_EnInDeToekomst1_HiddenFieldTabIndex').val();
$("ul.tabsScenario").tabs('select', tabIndex);

where the tab index is stored in a hidden field (HiddenFieldTabIndex). The above code works fine in Firefox, Chrome and Safari, but not in IE7 or IE8. I am using a ScriptManager and UpdatePanels, but in an extremely simple website example I can't even get the jquery.tools tabs tool to work. There are some unanswered posts on the Jquery.Tools forum concerning this topic, but yeah, that doesn't help much. I've already determined that the jquery.ui tabs tool works well after a postback but that would cost a lot of refactoring in our project as far as html and css goes. I'd like to avoid that.

View 4 Replies

Data Controls :: Preserve (Retain) Background Color Of DropDownList Item On PostBack

May 7, 2015

I have a dropdown populated with data , based on a true / false condition i change the dropdown item color when dropdown gets loaded initially the item color are proper based on condition. but if i select a particular item & then again click on dropdown the item color disappear show to retain the item color.

View 1 Replies

How To Use IEnumerable Interface

Jun 9, 2010

i was looking at one example on msdn [URL], but i can't really understand it.

View 1 Replies

Use Of IEnumerator And IEnumerable

Mar 14, 2010

refer me few article which describe the basic use of IEnumerator and IEnumerable,

View 3 Replies

ADO.NET :: How To Read IEnumerable

Mar 6, 2011

I have function it will return IEnumerable as.

IEM = myclass.getdata("name");

How to read the data in IEM as it consists of many columns. I have to display the values into labels and textboxes.

View 3 Replies

How To Convert List Into Ienumerable

May 1, 2010

I am using LINQ for data connectivity and have made class which return me the result set into presentation here is the syntax:-

public List<ClsDermaInvestigation> MthdisplayInvestigation()
{
List<ClsDermaInvestigation> lstinvst = new List<ClsDermaInvestigation>();
ISingleResult<USP_Patient_Dermatology_InvestigationResult> investresult = objderma.USP_Patient_Dermatology_Investigation(PatientID, RepDate, Hb, TLC, F);
foreach(USP_Patient_Dermatology_InvestigationResult rel in investresult)
{
ClsDermaInvestigation objinvest = new ClsDermaInvestigation();
objinvest.Albumin = Convert.ToDouble(rel.Albumin);
objinvest.ALP = rel.ALP;
objinvest.ANA = rel.ANA;
objinvest.Date = rel.date;
lstinvest.add(objinvest)}return lstinvest}
This list is returning me the result.It works fine but in 1 case am using the same list to bind my Date dropdownlist.
//aspx.cs code
List<Dermatology.ClsDermaInvestigation> objlstinvest = objinvest.MthdisplayInvestigation();
//Array s = objlstinvest.to
drpDate.DataSource = s;
drpDate.DataTextField = "Repdate";
drpDate.DataValueField = "Repdate";
drpDate.DataBind();

But it throws an error that list does not conatin a property with "Repdate";. How can i bind this list with dropdownlist?? Can i convert it into some type so that i would be able to bind it??

View 2 Replies

ADO.NET :: LINQ And Cast Row To IEnumerable?

Apr 1, 2011

table1 row = _db.table1.FirstOrDefault(r => r.ReferenceID == refNumber);

Is there anyway to cast row to IEnumerable?

((IEnumerable<table1>)row) - does not work

View 1 Replies

MVC :: Updating Model With IEnumerable?

Apr 19, 2010

I'm trying to update values I have stored in an IEnumerable using UpdateModel, but it isn't reflecting the changes when I step over it in Debug.I also tried upating it using a foreach loop and updating the values in each object T within the IEnumerable<T>. The values are changed at the object level, but it seems that the value of the object in the IEnumerable isn't being changed.I was looking at IEnumerable<T> and didn't see a way to update it... I'm thinking that I might have to assign the updates to some other data structure, then convert it to an IEnumerable or something before I try to save my repository

View 6 Replies

What Is The Difference Between IEnumerable And List

May 18, 2010

I've read some articles about this but for some reason they're just not doing it for me. I'd like to understand the difference between

IEnumerable<string> myList and List<string>myListToo

View 7 Replies

C# - Getting Two Different Data Types From IEnumerable?

Jun 29, 2010

I have IEnumerable object with value1 and value2. value2 is an array and value1 is string. I want to databind this object to Listview like that. So both value1 and value2[0] (always first item in array) could be accessed via <%# Eval("value1") %> and <%# Eval("value2") %> .

How to write expression to handle both items ?

ListViewItems.DataSource = f.Items.Select(t => t.value1, t.value2[0]);
ListViewItems.DataBind();

View 1 Replies

Convert Datatable To IENumerable?

Feb 10, 2010

Dim list As List(Of DataRow) = dt.AsEnumerable().ToList()When I compile I get the error:
'AsEnumerable' is not a member of 'System.Data.DataTable'.I added Imports system.data.datatableextensions to the file..This code works when I run it on a asp.net project But when I use the same code in Website it returns the above error..Can anyone help solve this error.

View 2 Replies

MVC :: IEnumerable - Null Files Parameter

Feb 3, 2010

i'm using MVC 2, RC, and i have a controller method:

[Code]....

and i have an <input type="file"../> in my form. during post, however, the files parameter is null.

View 9 Replies

MVC :: JsonResult Only Returns IEnumerable Data?

Mar 31, 2010

My controller has a member that returns a JsonResult object, it is coded as per below. The problem is that Json(users) only returns the data from IEnumerable (MembershipUserEx objects) and I also want the data from the public Properties of MembershipUserExCollection as well. Is there a way to do this? I guess I am looking for the Json object to look something like this pseudo object:

results = {
pageIndex:0,
pageSize:50,

[code]...

View 1 Replies

VS 2010 - Casting SiteMapNodeCollection To IEnumerable

Feb 19, 2013

Why it's not possible to cast a SiteMapNodeCollection (eg. SiteMap.CurrentNode.ChildNodes) to an IEnumerable<SiteMapNode>? I was wanting to do some filtering of the collection via LINQ, but this might not be possible?

The MSDN page says it implements IList, ICollection, and IEnumerable, so I don't see what the problem is.

View 4 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved