Hi Guys,
I have a label inside an update panel which I wouldl ike to use as a status bar.
Basically the user clicks a button which executes a main fucntion that performs a series of tasks. I'd like to inform the user as to the state of the function as it progresses e.g.:
Stage 1: Retrieving data...
Stage 2: Calculating values...
Stage 3: Printing values...
Stage 4: Done!
I've tried updating the updatepanel directly from the function but it only updates the panel at the end of function (stage 4) and shows "Done!" (which I understand is how it should work).
I've been looking into timers and threads to try and update the panel seperate to the main function but I thought I'd post here incase anyone has any better ideas?
Thanks for any help in advance!
John
bourkeyo is offline Reply With Quote
Hi,
I am working on VS 2008 and 3.5 framework.
I had three windows services.
I placed all three in a single solution, created installer individually for each of them.
Then created a setup project.
When I build it says build failed .
But I checked on the errorlist, (i enabled the diagnostics in options menu), but there was no error at all.
I went ahead and installed. There were no issues, But there was no service showed up in the services.msc.
I installed each service individually , using installutil command, it showed up.
But my requirement is to bundle these services and deploy to the client.
The client should install it.
Where am I going wrong.
Any inputs will be highly appreciated.
Regards
cmrhema
Let's assume I have two assemblies:
MyExecutable.dll version 1.0.0
MyClassLibrary.dll version 1.0.0
Now, MyExecutable.dll currently uses MyClassLibrary.dll's classes and methods (which include some algorithms). Most of those algorithms were made on the run, being that later I'll want to refine them if needed. This means, I won't change the interface of those classes but the code itself will see some changes.
The question at hand is, MyExecutable.dll will be expecting MyClassLibrary.dll 1.0.0 and I'll want it to use version 1.0.1 (or something like that). I don't want to have to recompile MyExecutable.dll(because actually there might be more than just one executable using MyClassLibrary.dll). Is there a solution for this problem? I've heard about the GAC, but if possible I'd like to stay away from it.
Thanks
I d like to execute a remote javascript which redirects the user to another page on my domain with data that s passes as query string. I want to get this data which is passed on to the page on my domain.
$.getScript('http://site.com/foo.js', function() {
**//foo.js redirects to another page on my domain with data
// and i d like to capture that data from this function,
// at least if i find the parameters that passed on there, i ll be fine.**
});
What to do ?
i am making a messenger over internet.
it has a server which listens to clients but when it try to send the reply to any request to client it shows the error of client not found.
however my clients are connecting to that server because it has a static ip address and live server.
having problem reaching client because they can be behind any firewall or network and dont have static ip addresses. so how can i reach to my client??
any Suggestions..
I am trying to optimize a piece of code that clones an object:
#region ICloneable
public object Clone()
{
MemoryStream buffer = new MemoryStream();
BinaryFormatter formatter = new BinaryFormatter();
formatter.Serialize(buffer, this); // takes 3.2 seconds
buffer.Position = 0;
return formatter.Deserialize(buffer); // takes 2.1 seconds
}
#endregion
Pretty standard stuff. The problem is that the object is pretty beefy and it takes 5.4 seconds (according ANTS Profiler - I am sure there is the profiler overhead, but still).
Is there a better and faster way to clone?
I have a custom DGV cell I'm using to display the contents of MyType objects. To control how they're being formatted I'm overriding the GetFormattedValue() and FormattedvalueType methods of DataGridViewTextBoxCell because in this case I don't want to use the default ToString() method. The problem is that when I do this the DGV is sorting the column by the string in FormattedValue instead of by Value.
I'm not seeing a method I can override to change the sort behavior of the column. While I know I can, I don't want to have to write custom Sort mthods for the DGVs themselves because I'm using this in multiple DGV's.
How to fill multiple tables in a dataset.
I m using a query that returns me four tables.
At the frontend I am trying to fill all the four resultant table into dataset.
Here is my Query. Query is not complete. But it is just a refrence for my Ques
Select * from tblxyz compute sum(col1)
suppose this query returns more than one table, I want to fill all the tables into my dataset
I am filling result like this
con.open();
adp.fill(dset);
con.close();
Now when i checks this dataset. It shows me that it has four tables but only first table data is being displayed into it. rest 3 dont even have schema also.
What i need to do to get desired output
I have a web app that is using the 3.5 framework. I wanted to know how can I detect what webhost is rendering the page.
If the server is localhost, then send email notification to [email protected]
If the server is QA, then send email to [email protected]
Thanks
When compiling this code:
public class WindsorControllerFactory : IControllerFactory
{
private readonly WindsorContainer _container;
public WindsorControllerFactory(WindsorContainer container)
{
_container = container;
}
public IController CreateController(RequestContext requestContext,
string controllerName)
{
return (IController)_container.Resolve(controllerName);
}
public void ReleaseController(IController controller)
{
_container.Release(controller);
}
}
I am getting this error:
'WindsorControllerFactory' does not
implement interface member
'System.Web.Mvc.IControllerFactory.CreateController(System.Web.Routing.RequestContext,
string)'
Well, it obviously implements this member. Has anyone encountered this problem?
While designing applications it is a very good practice to have all the business logic in one place. So why then we sometimes have the business logic in stored procs? Can we fetch all data from the DB and store it in a DataSet and then process it? What would be the performance of the app in this scenario?
In my most recent question: Unit Testing Best Practice? / C# InternalsVisibleTo() attribute for VBNET 2.0 while testing?, I was asking about InternalsVisibleToAttribute.
I have read the documentation on how to use it, and everything is fine and understood. However, I can't instantiate my class Groupe from my Testing project.
I want to be able to instantiate my internal class in my wrapper assembly, from my testing assembly.
Any help is appreciated!
EDIT
Here's the compile-time error I get when I do try to instantiate my type:
Erreur 2 'Carra.Exemples.Blocs.ActiveDirectory.Groupe' n'est pas accessible dans ce contexte, car il est 'Private'. C:\Open\Projects\Exemples\Src\Carra.Exemples.Blocs.ActiveDirectory\Carra.Exemples.Blocs.ActiveDirectory.Tests\GroupeTests.vb 9 18 Carra.Exemples.Blocs.ActiveDirectory.Tests
(This says that my type is not accessible in this context, because it is private.) But it's Friend (internal)!
I have the following method I came across in a code review. Inside the loop Resharper is telling me that if (narrativefound == false) is incorrect becuase narrativeFound is always true. I don't think this is the case, because in order to set narrativeFound to true it has to pass the conditional string compare first, so how can it always be true? Am I missing something? Is this a bug in Resharper or in our code?
public Chassis GetChassisForElcomp(SPPA.Domain.ChassisData.Chassis asMaintained, SPPA.Domain.ChassisData.Chassis newChassis)
{
Chassis c = asMaintained;
List<Narrative> newNarrativeList = new List<Narrative>();
foreach (Narrative newNarrative in newChassis.Narratives)
{
bool narrativefound = false;
foreach (Narrative orig in asMaintained.Narratives)
{
if (string.Compare(orig.PCode, newNarrative.PCode) ==0 )
{
narrativefound = true;
if (newNarrative.NarrativeValue.Trim().Length != 0)
{
orig.NarrativeValue = newNarrative.NarrativeValue;
newNarrativeList.Add(orig);
}
break;
}
if (narrativefound == false)
{
newNarrativeList.Add(newNarrative);
}
}
}
c.SalesCodes = newChassis.SalesCodes;
c.Narratives = newNarrativeList;
return c;
}
i have this code :
IEnumerable<string> q = customers /*EF entity*/
.Select (c => c.Name.ToUpper())
.OrderBy (n => n)
To select entity, ObjectContext actually create ObjectQuery, which
implement IQueryable. The object return from ObjectQuery, is not
normal object, but EntityObject
but what if i write : ( notice the var)
var q = customers /*EF entity*/
.Select (c => c.Name.ToUpper())
.OrderBy (n => n)
it can be determined both to ienumerable or iqueryable :
because ObjectQuery Also implements IEnumerable...
i dont know if there's any specific info which tell the compiler "use A and not B. A is more specific..." ( there must be...i just cant find it)
any help ? how will it know to use A || B ?
Hi, I have a AdvWebGrid where the 7th coloumn is DynEdit where user will enter the value.Now I have to take the enetered value and insert into the Sql tablel. For example i have 7 records in the grid the user will enter some comments for the first three record and save.Now i have to insert/update the first three comments in the table.
I'm utilizing the code posted by Jesper Palm here: http://stackoverflow.com/questions/280891/make-user-control-display-outside-of-form-boundry
/// <summary>
/// A simple popup window that can host any System.Windows.Forms.Control
/// </summary>
public class PopupWindow : System.Windows.Forms.ToolStripDropDown
{
private System.Windows.Forms.Control _content;
private System.Windows.Forms.ToolStripControlHost _host;
public PopupWindow(System.Windows.Forms.Control content)
{
//Basic setup...
this.AutoSize = false;
this.DoubleBuffered = true;
this.ResizeRedraw = true;
this._content = content;
this._host = new System.Windows.Forms.ToolStripControlHost(content);
//Positioning and Sizing
this.MinimumSize = content.MinimumSize;
this.MaximumSize = content.Size;
this.Size = content.Size;
content.Location = Point.Empty;
//Add the host to the list
this.Items.Add(this._host);
}
}
I've translated it to VB:
Public Class PopupWindow
Inherits System.Windows.Forms.ToolStripDropDown
Private _content As System.Windows.Forms.Control
Private _host As System.Windows.Forms.ToolStripControlHost
Public Sub New(ByVal content As System.Windows.Forms.Control)
Me.AutoSize = False
Me.DoubleBuffered = True
Me.ResizeRedraw = True
Me._content = content
Me._host = New System.Windows.Forms.ToolStripControlHost(content)
Me.MinimumSize = content.MinimumSize
Me.MaximumSize = content.MaximumSize
Me.Size = content.Size
content.Location = Point.Empty
Me.Items.Add(Me._host)
End Sub
End Class
It works great with a PictureBox showing its information. But for some reason I cannot get the DataGridView to display anything when it is in the popup.
If I pull the grid out of the popup it displays all of its information fine. If I pause during debug, the grid shows that it has all the data in it. It's just not displaying anything.
Does anybody have any ideas?
Hai,
I am using Visual Studio 2008 and Framework 3.5. I wrote a WebService and I added that WebService in my page through ScriptManager Service Path. I wrote a method in the webservice, that returns List<.... I captured that value from JavaScript function. Now I want to bind that List<... value to with my Asp:GridView using JavaScript. Help me .....
I am new to WebAPI.
I have a MVC project and webApi project both reside under the **same solution**. Also, BLL Class library and DAL class library reside under the same solution.
Earlier, my MVC project will talk to the BLL now I am trying to create a WebAPi project which stands in between MVC and BLL.
Here is what I have come up with so far :
I'm using the HTTPClient to post to a WebApi project. My post method on my controller accepts a single parameter (a model).
StatsCriteria criteria = new StatsCriteria();
......
var client = new HttpClient();
var response = client.PostAsJsonAsync("http://localhost:52765/api/reports", criteria).Result;
.......
Here's the signature for my controller in Webapi
[HttpPost]
public CMAReportVM Reports([FromBody] StatsCriteria criteria)
{
var cmaReport = Service3.GetCMAReport(criteria.Mlsnums);
//Create Map to enable mapping business object to View Model
Mapper.CreateMap<CMAReport, CMAReportVM>();
// Maps model to VM model class
var cmaVM = Mapper.Map<CMAReport, CMAReportVM>(cmaReport);
reutn cmaVM;
}
// and here's my routing:
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
I am getting the following
405 : Method not allowed.
As the WebAPI and MVC project both reside under same sloution I am not sure where/how to host my webapi.
I'm fetching more than 10 millions of records from database and writing to a text file. It takes hours of time to complete this operation. Is there any option to use TPL features here?
It would be great if someone could get me started implementing this with the TPL.
using (FileStream fStream = new FileStream("d:\\file.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite))
{
BufferedStream bStream = new BufferedStream(fStream);
TextWriter writer = new StreamWriter(bStream);
for (int i = 0; i < 100000000; i++)
{
writer.WriteLine(i);
}
bStream.Flush();
writer.Flush(); // empty buffer;
fStream.Flush();
}
This is really driving me crazy. I've got a button inside a gridview to remove that item from the gridview (its datasource is a list). I've got the list being saved to session anytime a change is being made to it, and on page_load check if that session variable is empty, if not, then set that list to bind to the gridview.
Code Behind:
Public accomplishmentTypeDao As New AccomplishmentTypeDao()
Public accomplishmentDao As New AccomplishmentDao()
Public userDao As New UserDao()
Public facultyDictionary As New Dictionary(Of Guid, String)
Public facultyList As New List(Of User)
Public associatedFaculty As New List(Of User)
Public facultyId As New Guid
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'If Not Session("associatedFaculty") Is Nothing Then'
' Dim associatedFacultyArray As User() = DirectCast(Session("associatedFaculty"), User())'
' associatedFaculty = associatedFacultyArray.ToList()'
'End If'
Page.Title = "Add a New Faculty Accomplishment"
ddlAccomplishmentType.DataSource = accomplishmentTypeDao.getEntireTable()
ddlAccomplishmentType.DataTextField = "Name"
ddlAccomplishmentType.DataValueField = "Id"
ddlAccomplishmentType.DataBind()
facultyList = userDao.getListOfUsersByUserGroupName("Faculty")
For Each faculty As User In facultyList
facultyDictionary.Add(faculty.Id, faculty.LastName & ", " & faculty.FirstName)
Next
If Not Page.IsPostBack Then
ddlFacultyList.DataSource = facultyDictionary
ddlFacultyList.DataTextField = "Value"
ddlFacultyList.DataValueField = "Key"
ddlFacultyList.DataBind()
End If
gvAssociatedUsers.DataSource = associatedFaculty
gvAssociatedUsers.DataBind()
End Sub
Protected Sub deleteUser(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.CommandEventArgs)
facultyId = New Guid(e.CommandArgument.ToString())
associatedFaculty.Remove(associatedFaculty.Find(Function(user) user.Id = facultyId))
Session("associatedFaculty") = associatedFaculty.ToArray()
gvAssociatedUsers.DataBind()
upAssociatedFaculty.Update()
End Sub
Protected Sub btnAddUser_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnAddUser.Click
facultyId = New Guid(ddlFacultyList.SelectedValue)
associatedFaculty.Add(facultyList.Find(Function(user) user.Id = facultyId))
Session.Add("associatedFaculty", associatedFaculty.ToArray())
gvAssociatedUsers.DataBind()
upAssociatedFaculty.Update()
End Sub
Protected Sub Delete(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.CommandEventArgs)
End Sub
End Class
Markup:
<asp:UpdatePanel ID="upAssociatedFaculty" runat="server"
UpdateMode="Conditional">
<ContentTemplate>
<p><b>Created By:</b> <asp:Label ID="lblCreatedBy" runat="server"></asp:Label></p>
<p><b>Accomplishment Type: </b><asp:DropDownList ID="ddlAccomplishmentType" runat="server"></asp:DropDownList></p>
<p><b>Accomplishment Applies To: </b><asp:DropDownList ID="ddlFacultyList" runat="server"></asp:DropDownList>
<asp:Button ID="btnAddUser" runat="server" Text="Add Faculty" OnClientClick="incrementCounter();" /></p>
<p>
<asp:GridView ID="gvAssociatedUsers" runat="server" AutoGenerateColumns="false"
GridLines="None" ShowHeader="false">
<Columns>
<asp:BoundField DataField="Id" HeaderText="Id" Visible="False" />
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<span style="margin-left: 15px;">
<p><%#Eval("LastName")%>, <%#Eval("FirstName")%>
<asp:Button ID="btnUnassignUser" runat="server" CausesValidation="false"
CommandArgument='<%# Eval("Id") %>' CommandName="Delete" OnCommand="deleteUser" Text='Remove' /></p>
</span>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
<em>There are currently no faculty associated with this accomplishment.</em>
</EmptyDataTemplate>
</asp:GridView>
</p>
</ContentTemplate>
</asp:UpdatePanel>
Now here is the crazy part I am simply boggled by, if I uncomment the If Not Session... block of page_load, then deleteUser will never fire when btnUnassignUser is clicked. If I keep it commented out...it fires no problem, but then of course my list can never have more than one item since I am not loading the saved list from session into the gridview but just a fresh one. But the button click is being registered, because page_load is being stepped through again when I am viewing in debug mode, just deleteUser never fires.
Why is this happening?? And how can I fix it??
When are predicates appropriate and what is the best pattern for usage? What are the advantages of predicates?
It seems to me like most cases where a predicate can be employed a tight loop would accomplish the same functionality?
I don’t see a reusability argument given you will probably only implement a predicate in one method right?
They look and feel nice but besides that they seem like you would only employ them when you need a quick hack on the collection classes?
UPDATE
But why would you be rewriting the tight loop again and again?
In my mind/code when it comes to collections I always end up with something like
Class Person
End Class
Class PersonList
Inherits List(Of Person)
Function FindByName(Name) as Person
tight loop....
End Function
End Class
@Ani
By that same logic I could implement the method as such
Class PersonList
Inherits List(Of Person)
Function FindByName(Name) as PersonList
End Function
Function FindByAge(Age) as PersonList
End Function
Function FindBySocialSecurityNumber(SocialSecurityNumber) as PersonList
End Function
End Class
And call it as such
Dim res as PersonList = MyList.FindByName("Max").FindByAge(25).FindBySocialSecurityNumber(1234)
and the result along with the amount of code and its reusability is largely the same, no?
I am not arguing just trying to understand.
Hi guys,
I started to use the new ConcurrentDictionary from .Net4 yesterday to implement a simple caching for a threading project.
But I'm wondering what I have to take care of/be careful about when using it?
What have been your experiences using it?
Hi,
is there a way to programmatically set and remove the ErrorTemplate of an Control without
the whole Validation mechanism? Basically, what I'd like to do, is to retrieve the ErrorTemplate of an Control at some point like this:
ControlTemplate errTemplate = Validation.GetErrorTemplate(myTxtBx);
and temporarily use it as it's ControlTemplate like this:
myTxtBx.Template = errTemplate;
Can you somehow do this?