how can i programmatically restart page lifecycle? i do some stuff in controls events which affects these controls. to see changes i have to draw page again. how can i do it?
Hi every one!
Does Page class adds ViewState for Controls created in CreateChildControls, I mean I have a page which I add some controls to the page and all of them are Literal and EnableViewState is false, my question is are there any ViewState entry gor them in Page's ViewState?
Thank you.
What is the best way to determine if a user belongs to particular AD user group using C# without have to enumerate through all the user's groups. Can this be done using a single LDAP query or search?
I have an existing WebForms project to which I'm adding MVC pages. I created an MVC project and copied the project type guids.
It works fine, but I can't get Visual Studio to display the "Add Controller" or "Add View" wizards on my controllers and views directories (they're not /Controllers and /Views, they're in /Foo/Controllers and /Foo/Views).
Is it possible to enable the wizards?
Senerio
We have an application that records incidents. An external database needs to be queried when an incident is approved by a supervisor. The queries to this external database are sometimes taking a while to run. This lag is experienced through the browser.
Possible Solution
I want to use threading to eliminate the simulated hang to the browser. I have used the Thread class before and heard about ThreadPool. But, I just found BackgroundWorker in this post.
MSDN states:
The BackgroundWorker class allows you to run an operation on a separate, dedicated thread. Time-consuming operations like downloads and database transactions can cause your user interface (UI) to seem as though it has stopped responding while they are running. When you want a responsive UI and you are faced with long delays associated with such operations, the BackgroundWorker class provides a convenient solution.
Is BackgroundWorker the way to go when handling long running queries?
What happens when 2 or more BackgroundWorker processes are ran simultaneously? Is it handled like a pool?
How can i make a cached object re-cache it self with updated info when the cache has expired? I'm trying to prevent the next user who request the cache to have to deal with getting the data setting the cache then using it is there any background method/event i can tie the object to so that when it expires it just calls the method it self and self-caches.
Our globalization mechanism stores error messages in a SQL 2005 DB.
Some of the error messages are used as subjects on email messages sent to the development team.
Recently, with no clear reason, we started receiving emails with strangely encoded subjects, such as:
=?utf-8?B?Qm1mQm92ZXNwYS5Qb3NUcmFkaW5nRXNwZWNpZmljYWNhbyAtIFN1Y2Vzc28gbm8gcmVwcm
9jZXNzYW1lbnRvLiBEYXRhIFByZWfDo28gPSAzMS8wMy8yMDEwIDAwOjAwOjAwIC0gTsO6bWVyby
BkbyBFdmVudG8gZGUgTmVnw7NjaW8gPSAxMDAyIC0gQ8OzZGlnbyBOYXR1cmV6YSBkYSBPcGVyY
cOnw6NvID0gQyAtIFNlcn...
We don't have any clue on the reason this is happening, nor which encoding pattern is being used here (maybe utf-8?).
I'd really appreciate some help.
Hello.
I've got a really difficult bug and I can't see the fix. The subject drives me insane for real for a long time. Let's consider the following scenario:
1) There is a PowerPoint 2003 presentation. It contains the only slide and the only shape, but the shape contains a text frame including a bulleted list with a random textual representation structure.
2) There is a requirement to get bullet indents for every bulletted paragraph using PowerPoint 2007. I can satisfy the requirement opening the presentation in the compatibility mode and applying the following VBA script:
With ActivePresentation
Dim sl As Slide: Set sl = .Slides(1)
Dim sh As Shape: Set sh = sl.Shapes(1)
Dim i As Integer
For i = 1 To sh.TextFrame.TextRange.Paragraphs.Count
Dim para As TextRange: Set para = sh.TextFrame.TextRange.Paragraphs(i, 1)
Debug.Print para.Text; para.indentLevel, sh.TextFrame.Ruler.Levels(para.indentLevel).FirstMargin
Next i
End With
that produces the following output:
A 1 0
B 1 0
C 2 24
D 3 60
E 5 132
Obviously, everything is perfect indeed: it has shown the proper list item text, list item level and its bullet indent. But I can't see the way of how I can reach the same result using C#. Let's add a COM-reference to Microsoft.Office.Interop.PowerPoint 2.9.0.0 (taken from MSPPT.OLB, MS Office 12):
// presentation = ...("presentation.ppt")... // a PowerPoint 2003 presentation
Slide slide = presentation.Slides[1];
Shape shape = slide.Shapes[1];
for (int i = 1; i<=shape.TextFrame.TextRange.Paragraphs(-1, -1).Count; i++) {
TextRange paragraph = shape.TextFrame.TextRange.Paragraphs(i, 1);
Console.WriteLine("{0} {1} {2}", paragraph.Text, paragraph.IndentLevel, shape.TextFrame.Ruler.Levels[paragraph.IndentLevel].FirstMargin);
}
Oh, man... What's it? I've got problems here. First, the paragraph.Text value is trimmed until the '\r' character is found (however paragraph.Text[0] really returns the first character O_o). But it's ok, I can shut my eyes to this. But... But, second, I can't understand why the first margins are always zero and it does not matter which level they belong to. They are always zero in the compatibility mode... It's hard to believe it... :) So is there any way to fix it or just to find a workaround? I'd like to accept any help regarding to the solution of the subject. I can't even find any article related to the issue. :( Probably you have ever been face to face with it... Or is it just a bug with no fix and must it be reported to Microsoft?
Thanks you.
Currently, I cannot use Paypal Pro on my host (GoDaddy) because it requires Full trust level.
After digging in Google, it seems a workaround is possible by adding
AllowPartiallyTrustedCallersAttribute to the Paypal assembly. I have seen code samples that use AllowPartiallyTrustedCallersAttribute in their AssemblyInfo.cs file, however, I've yet to run into a code example that also happens to be using PayPal.
My question is where should the AllowPartiallyTrustedCallersAttribute be added in my project if my objective is to make the PayPal assembly work? I have tried adding it to my AssemblyInfo.cs for the project that contains the entire website, but I have not been successful.
At this point, any insight or shot in the dark would be greatly appreciated. Even if someone could point me in the general direction of some documentation I would be grateful.
AllowPartiallyTrustedCallersAttribute Reference:
http://msdn.microsoft.com/en-us/library/system.security.allowpartiallytrustedcallersattribute.aspx
I am experiencing an issue where the string drawn on an image is putting non-letter characters in the wrong place, i.e. Hello World! draws on the jpg !Hello World
anyone else seen this?
I have an aspx page that is supposed to reference a code-behind variable but I am receiving an error of "The name [variable] does not exist in the current context"
Here is the aspx code
<%@ Control Language="C#" AutoEventWireup="true" Inherits="IPAM.Website.Controls.controls_event_header" Codebehind="event_header.ascx.cs" %>
<%# strEventLink %>
<h3><%# strEventDate %></h3>
<%# strLinks %>
Here is part of the aspx.cs code declaring those variables:
public string strEventLink = "";
public string strEventDate;
public string strLinks = "";
Here is the part of the aspx.cs code where it sets those variables:
strEventLink = "<h2>" + parent.Name + "</h2>";
strLinks += "<p><font size=\"+1\"><a href=\"" + Page.ResolveUrl("~" + strScheduleLink) + "\"><b>" + strScheduleLinkText + "</b></a></font></p>\n";
strEventDate = ei.DateSpan;
Please help me with this problem
Hello!
I want 4 general RegEx expressions for the following 4 basic cases:
Up to A chars starting after B chars from start of line on up to C lines starting after D lines from start of file
Up to A chars starting after B chars from start of line on up to C lines occurring before D lines from end of file
Up to A chars starting before B chars from end of line on up to C lines starting after D lines from start of file
Up to A chars starting before B chars from end of line on up to C lines starting before D lines from end of file
These would allow to select arbitrary text blocks anywhere in the file.
So far I have managed to come up with cases that only work for lines and chars separately:
(?<=(?m:^[^\r]{N}))[^\r]{1,M} = UP
TO M chars OF EVERY LINE, AFTER FIRST
N chars
[^\r]{1,M}(?=(?m:.{N}\r$))
= UP TO M chars OF EVERY LINE, BEFORE LAST N chars
The above 2 expressions are for chars, and they return MANY matches (one for each line).
(?<=(\A([^\r]*\r\n){N}))(?m:\n*[^\r]*\r$){1,M} = UP TO M lines AFTER FIRST N lines
(((?=\r?)\n[^\r]*\r)|((?=\r?)\n[^\r]+\r?)){1,M}(?=((\n[^\r]*\r)|(\n[^\r]+\r?)){N}\Z) = UP TO M lines BEFORE LAST N lines from end
These 2 expressions are equivalents for the lines, but they always return just ONE match.
The task is to combine these expressions to allow for scenarios 1-4. Anyone can help?
Note that the case in the title of the question, is just a subclass of scenario #1, where both B = 0 and D = 0.
EXAMPLE:
SOURCE:
line1 blah 1
line2 blah 2
line3 blah 3
line4 blah 4
line5 blah 5
line6 blah 6
DESIRED RESULT: Characters 3-6 of lines 3-5: A total of 3 matches:
<match>ne3 </match>
<match>ne4 </match>
<match>ne5 </match>
i have the following code
Private Sub select_color_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles select_color.Click
Dim ocolor As New ColorDialog
ocolor.ShowDialog()
Me.BackColor = ocolor.Color
End Sub
and it changes the background color of form to the color i select in colordialogue...
now i want to change the BGColor of shockwaveobject in this way...however i can change the BGColor of shockwave object manually in toolbox but i want to change it by color dialogue how can i do that...
Here is a code snippet from DirectShowNet library, used to open a video file:
this.graphBuilder = (IGraphBuilder) new FilterGraph();
// Have the graph builder construct its the appropriate graph automatically
hr = this.graphBuilder.RenderFile(filename, null);
but the RenderFile method fails. At the same time, Windows Media Player opens the same file nicely. What can be the problem.
I got the same behavior without DirectShowNet, but using native C++ code...
Hi all,
I have a little bit seen the representation of an array in memory with Windbg and SOS plugin.
Here it is the c# :
class myobj{
public int[] arr;
}
class Program{
static void Main(string[] args){
myobj o = new myobj();
o.arr = new int[7];
o.arr[0] = 0xFFFFFF;
o.arr[1] = 0xFFFFFF;
o.arr[2] = 0xFFFFFF;
o.arr[3] = 0xFFFFFF;
o.arr[4] = 0xFFFFFF;
}
}
I break at final of Main, and I observ :
0:000> !clrstack -l
OS Thread Id: 0xc3c (0)
ESP EIP
0015f0cc 0043d1cf test.Program.Main(System.String[])
LOCALS:
0x0015f0d8 = 0x018a2f58
0:000 !do 0x018a2f58
Name: test.myobj
MethodTable: 0026309c
EEClass: 00261380
Size: 12(0xc) bytes
(C:\Users\admin\Documents\Visual Studio 2008\Projects\test\test\bin\Debug\test.exe)
Fields:
MT Field Offset Type VT Attr Value Name
01324530 4000001 4 System.Int32[] 0 instance 018a2f64 tab
0:000 dd 018a2f64
018a2f64 01324530 00000007 00ffffff 00ffffff
018a2f74 00ffffff 00ffffff 00ffffff 00000000
018a2f84 00000000 00000000 00000000 00000000
018a2f94 00000000 00000000 00000000 00000000
018a2fa4 00000000 00000000 00000000 00000000
018a2fb4 00000000 00000000 00000000 00000000
018a2fc4 00000000 00000000 00000000 00000000
018a2fd4 00000000 00000000 00000000 00000000
I can see that the header contains the size of the array (00000007) but my question is : what is the value 01324530 ?
Thanks !
Hi,
Having a problem with the dataGridView control being populated with Display members:
The data is loaded, but it doesn't display the value/displaymember
For info here is the dataset config:
Am I missing something??
Can anybody please help me with this as I have no idea why
public IHttpHandler GetHttpHandler(RequestContext requestContext)
is not executing. In my Global.asax.cs I have
public class MvcApplication : System.Web.HttpApplication
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
routes.Add("ImageRoutes", new Route("Images/{filename}", new CustomRouteHandler()));
}
protected void Application_Start()
{
RegisterRoutes(RouteTable.Routes);
}
}
//CustomRouteHandler implementation is below
public class CustomRouteHandler : IRouteHandler
{
public IHttpHandler GetHttpHandler(RequestContext requestContext)
{
// IF I SET A BREAK POINT HERE IT DOES NOT HIT FOR SOME REASON.
string filename = requestContext.RouteData.Values["filename"] as string;
if (string.IsNullOrEmpty(filename))
{
// return a 404 HttpHandler here
}
else
{
requestContext.HttpContext.Response.Clear();
requestContext.HttpContext.Response.ContentType = GetContentType(requestContext.HttpContext.Request.Url.ToString());
// find physical path to image here.
string filepath = requestContext.HttpContext.Server.MapPath("~/logo.jpg");
requestContext.HttpContext.Response.WriteFile(filepath);
requestContext.HttpContext.Response.End();
}
return null;
}
}
Can any body tell me what I'm missing here. Simply
public IHttpHandler GetHttpHandler(RequestContext requestContext) does not fire.
I havn't change anything in the web.config either. What I'm missing here? Please help.
I have a page that performs a long-running task (10 to 15 seconds) in the page_load method.
I have client-side javascript code that will display a decent "page loading" animated gif to the user.
I am able to invoke the JavaScript method from the code-behind, to display the "page loading" animated gif, however, the long-running task is hanging up the UI such that the animated gif doesn't actually display until after the long-running task is complete, which is the exact opposite of what I want.
To test this out, in my page_load method I make a call to the JavaScript method to display the animated gif. Then, I use Thread.Sleep(10000). What happens is that the animated gif doesn't display until after Thread.Sleep is complete.
Obviously I am doing something incorrect.
Any advice would be appreciated.
Thanks.
Chris
there is one linkbtn , on click i have to display word document content inside any textBox which supports, i used simple textbox but am facing the formatting problem. and also it does not show image. there is any idea for problem in display word document content inside any textBox .
i dont know about richtextbox, can i get any help, please send me desired code to [email protected]
I want to redirect all url errors
The url I want to cath is ~/bla/foo
It should redirect to ~/error404.aspx
bla exists as a folder. foo does not exist.
I already set the webconfig to point to my error but I just doesn't work. I get this error:
Server Error in application /.
-------------------------------------------------- ------------------------------
The source can not be found.
Description: HTTP 404. Perhaps you are looking for the source (or a dependency thereof) removed or is temporarily unavailable or has changed its name. Check the spelling of the URL.
Requested URL: / bla/foo.asox
I google translate this error cuz VS here is language specific.
What can I do to resolve this??? I want to point to ~/error404.aspx
I have a route defined with several hardcoded (non-parameter) segments:
routes.MapRoute(null, "suggestion/list/by/{tag}",
new { controller = "Suggestion", action = "List", tag = UrlParameter.Optional });
Suppose I'm in the Index view of SuggestionController, which has a Suggestion object for Model, how can I create a link that matches that route?
I'd rather use one of the provided helpers and keep the route name as null in order to avoid hard-coding to much on my views, but I can't figure out how to user these non-parameter segments in Html.ActionLink or RouteLink methods.
I've even tried to render the link using plain ol' html
<a href="/suggestion/list/by/<%=Model.Tag %>"><%=Model.Tag %></a>
but this somehow didn't match the route either. There's probably a very simple solution and I might be over-complicating things in mi mind, but I'm at a loss.
Any ideas?
Thanks in advance.
Hello all,
I need to create a newsletters by URL. I to do next:
Create a WebClient;
Use WebClient's method
DownloadData to get a source of page
in byte array;
Get string from source-html byte
array and set it to the newsletter
content.
But I have some troubles with paths. All elements' sources were relative (/img/welcome.png) but I need absolute (http://www.mysite.com/img/welcome.png).
How can I do this?
Best regards, Alex.
Hello everybody,
I have ascx partial view with html-layout like that
<%=Html.ActionLink<PersonController>(x => x.Publications(param1, param2, ... )) %>
My ascx is pretty big & I'd like to reuse it, changing controller/method in Html.ActionLink with another controller/method. Method of another controller has the same signature as PersonController.Publications. Please, suggest me the best way how to make controller/method configurable for my layout.
Thank you in advance