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?
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?
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.
Hello,
I have tried to set EnableViewStateMac to false but sometime the aspx page still gets the Invalid ViewState error. Modifying machine.config is impossible in this case. Don't know what to do. Please help!
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.
Im trying to create a custom version of the RequiredAttribute to replace the built in one and I've got it working for properties that have strings values, but with properties that are DateTime or integer for example, the default RequiredAttribute seems to be applied automatically (IF the property is not nullable!)
My problem is that i want to be able to specify a DateTime property as required using my custom required validator which gets the error message from a resources file (I don't want to have to tell the RequiredAttribute the type of the resource file and the key every time i apply it. That is why I'm making a custom one.)
How can i prevent the framework from applying the required attribute to properties of type DateTime and int etc without changing them to nullable.
Thanks
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'm starting a web application that contains the following projects:
Booking.Web
Booking.Services
Booking.DataObjects
Booking.Data
I'm using the repository pattern in my data project only. All services will be the same, no matter what happens. However, if a customer wants to use Access, it will use a different data repository than if the customer wants to use SQL Server.
I have StructureMap, and want to be able to do the following:
Web project is unaffected. It's a web forms application that will only know about the services project and the dataobjects project.
When a service is called, it will use StructureMap (by looking up the bootstrapper.cs file) to see which data repository to use.
An example of a services class is the error logging class:
public class ErrorLog : IErrorLog
{
ILogging logger;
public ErrorLog()
{
}
public ErrorLog(ILogging logger)
{
this.logger = logger;
}
public void AddToLog(string errorMessage)
{
try
{
AddToDatabaseLog(errorMessage);
}
catch (Exception ex)
{
AddToFileLog(ex.Message);
}
finally
{
AddToFileLog(errorMessage);
}
}
private void AddToDatabaseLog(string errorMessage)
{
ErrorObject error =
new ErrorObject
{
ErrorDateTime = DateTime.Now,
ErrorMessage = errorMessage
};
logger.Insert(error);
}
private void AddToFileLog(string errorMessage)
{
// TODO: Take this value from the web.config instead of hard coding it
TextWriter writer = new StreamWriter(@"E:\Work\Booking\Booking\Booking.Web\Logs\ErrorLog.txt", true);
writer.WriteLine(DateTime.Now.ToString() + " ---------- " + errorMessage);
writer.Close();
}
}
I want to be able to call this service from my web project, without defining which repository to use for the data access. My boostrapper.cs file in the services project is defined as:
public class Bootstrapper
{
public static void ConfigureStructureMap()
{
ObjectFactory.Initialize(x =>
{
x.AddRegistry(new ServiceRegistry());
}
);
}
public class ServiceRegistry : Registry
{
protected override void configure()
{
ForRequestedType<IErrorLog>().TheDefaultIsConcreteType<Booking.Services.Logging.ErrorLog>();
ForRequestedType<ILogging>().TheDefaultIsConcreteType<SqlServerLoggingProvider>();
}
}
}
What else do I need to get this to work? When I defined a test, the ILogger object was null.
Thanks,
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...
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
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...
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
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??
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 !
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.
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.
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]
accidently my code suggestion box [ the box when we start typing it shows us code suggestions ] is closed and i don't know how... now how can i enable that ??
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.
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 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 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, Actually I'm trying to capture person's current and permanent address. In this case if d current and permanent address same means no need to enter twise. Here I'm using a checkbox. If d checkbox s checked the current address plased in permanent address too. Help me to do tat.