|
Think I got it this time.
As you cannot reference your startup project which defines the controls you could either
move the controls to your second project and reference this in your startup project, so you can still use the controls there or
create a third project which contains the controls and is referenced by your two existing projects.
www.troschuetz.de
|
|
|
|
|
Hi all
I'm a newbie to C# and trialing the mail checker 1.0. What I would like to do is extend the source code so that when I receive a new mail notifier for 1 new message, I can click text in that box and be taken to that email in my default email client. Is this difficuilt to do? Does anyone have sample code I could refer to for ideas?
Your help is greatly appreciated.
|
|
|
|
|
We can't tell you if it's difficult to do, because that functionality is specific to the product (unless someone else looking at this has actually used it). If you have questions about a specific product, you need to ask the company (developer forums, newsgroups, whatever the company might have). This forum is for questions relating to C# and the .NET Framework, not for specific products (that's what a company's support sections/teams are for).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi all,
I have a tricky situation, with which I would very much appreciate a little advice:
I have a C# Control for embedding a flash swf in a page.
The 'codebase' and 'pluginspage' attributes of the object tag require urls
(e.g. http://www.macromedia.com/go/getflashplayer)
If the page is being served over https, of course that url should change to:
https://www.macromedia.com/go/getflashplayer
...to prevent the browser alerting you about mixing secure and non-secure objects.
Now here's the problem:
Our hosting environment has a linux server as the only outward-facing IP, and we are using the apache proxy pass module to serve our .net sites from a windows machine.
So the linux box serves on http or https. The windows box is only http.
My C# control, sitting on the windows box needs to know which to embed the flash as.
I hoped I could use the IsSecureConnection property of the request object, but that only sees the request from the linux box, which is http.
The full path of the url is no help either - same thing.
I hope I have explained this sufficiently well. If anyone has any ideas I would love to hear them.
Many thanks
Steven
|
|
|
|
|
Any future questions about ASP.NET (in any language) should actually be posted in the ASP.NET[^] forum.
ASP.NET will only know what it is asked. If the linux box is asking requesting a resource over HTTP, that's all it will know. You need some way to tell the Windows box which is being requested. I recommend taking a look at the apache mod APIs for that caching proxy mod you're using to see if there's any exported APIs, otherwise there's really no way to tell.
One more idea is to actually have to separate URLs (they could map the same directory/file, though) so that the ASP.NET page (or whatever) can easily distinguish between the two requests. You can't use IIS's virtual directory functionality because this will actually create a separate web application with a different AppDomains. Instead, you could either use two separate pages or use a custom IHttpHandler implementation which is pretty easy. Read a recent article in MSDN, Serving Dynamic Content with HTTP Handlers[^], for a good example and discussion.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi Heath,
Thank you so much for replying so fully, and I'm sorry I haven't got back to you till now.
Point taken about which forum this should be on.
The separate URL idea could be a winner, also I noticed the REMOTE_PORT header variable is different in both cases so may be able to do something there.
I read the articles on HTTP Handlers, thank you - very interesting.
In fact though, I thought of a rather lazy, well - frankly low down and dirty way of getting around this:
I can just have the codebase url as https the whole time! It seems to work perfectly well and is certainly a lot more straight forward. Do you think this is sufficient?
Thank you again for getting back to me
Best Wishes
Steven
|
|
|
|
|
It would work, but you're putting an extra burden on the client and server to encrypt communications to send the control(s). It may be negligible, however, so it really is up to your implementation.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi
I have a problem which I think is basically due to my lack of understanding as to the order that events are processed.
I have an .aspx page to which I want to programtically add all its controls (so that I can change the look of the application by simply modifying a couple of classes). I've based this on Peter Provost's article "ASP.Net Templates - Using Inheritance" (http://www.codeproject.com/aspnet/page_templates.asp).
The code almost works except that not all of my controls get added to my form as intended - the earlier-added ones do, the later-added ones do not. This is the kind of rendered HTML I get:
<div><label for="txt4">4</label><input name="txt4" id="txt4" type="text" /></div>
<div><label for="txt5">5</label><input name="txt5" id="txt5" type="text" /></div>
<form name="frmApp" method="post" action="company.aspx" id="frmApp">
<input type="hidden" name="__VIEWSTATE" value="dDw1MzgxOzs+kxSQNMEmk8WT5ck725Xa7SNOEg4=" />
<div><label for="txt0">0</label><input name="txt0" id="txt0" type="text" /></div>
<div><label for="txt1">1</label><input name="txt1" id="txt1" type="text" /></div>
<div><label for="txt2">2</label><input name="txt2" id="txt2" type="text" /></div>
<div><label for="txt3">3</label><input name="txt3" id="txt3" type="text" /></div>
</form>
My guess is that this is because the later-added controls have not been correctly initialised before the page is rendered.
Can anyone enlighten me?
Many thanks in advance.
Gary
==============
The .aspx file
==============
<%@ Page Inherits="CompanyPage" Src="classes/company_page.cs" %>
====================
The Code-behind file
====================
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using MyNamespace;
public class CompanyPage : MyNamespace.ExtendedPage{
//--------------------------------------------------------------------------------------------------
protected override void OnInit(System.EventArgs e){
for(int i = 0; i < 10; i++){
//add some text boxes and labels to the page
this.AddTextBox("Text" + i, "txt" + i);
}
base.OnInit(e);
}
//--------------------------------------------------------------------------------------------------
}
===========================
The Base Classes (compiled)
===========================
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
namespace MyNamespace{
public class BasicPage : System.Web.UI.Page{
//--------------------------------------------------------------------------------------------------
protected String Footer{
get{
return("...</body></html>");
}
}
//--------------------------------------------------------------------------------------------------
protected String Header{
get{
return("<html><head>...");
}
}
//--------------------------------------------------------------------------------------------------
}
public class ExtendedPage : BasicPage{
//--------------------------------------------------------------------------------------------------
protected void AddTextBox(String strLabel, String strName){
this.Controls.Add(new LiteralControl("<div>"));
this.Controls.Add(new LiteralControl("<label for=\"" + strName + "\">" + strLabel + "</label>"));
HtmlInputText ctrl = new HtmlInputText();
ctrl.ID = strName;
this.Controls.Add(ctrl);
this.Controls.Add(new LiteralControl("</div>\n"));
}
//--------------------------------------------------------------------------------------------------
private void AddExistingControls(HtmlForm form){
//****************************************************
// Add existing controls to form and remove from class
//****************************************************
for(int i = 0; i < this.Controls.Count; i++){
//get first control in collection
System.Web.UI.Control ctrl = this.Controls[0];
//add control to form
form.Controls.Add(ctrl);
//remove control (gets added back along with form in BuildPage)
this.Controls.Remove(ctrl);
}
}
//--------------------------------------------------------------------------------------------------
protected void BuildPage(HtmlForm form){
//***************
// Build the page
//***************
//this.Controls.Clear();
//add page header
this.Controls.AddAt(0, new LiteralControl(Header));
//add form
this.Controls.Add(form);
//add page footer
this.Controls.Add(new LiteralControl(Footer));
}
//--------------------------------------------------------------------------------------------------
private HtmlForm GetForm(){
//********************************************************
// Returns HtmlForm containing controls added to sub-class
//********************************************************
HtmlForm form = new HtmlForm();
form.ID = "frmApp";
//objects passed by reference!
AddExistingControls(form);
return form;
}
//--------------------------------------------------------------------------------------------------
protected override void OnInit(System.EventArgs e){
BuildPage(GetForm());
base.OnInit(e);
}
//--------------------------------------------------------------------------------------------------
}
}
|
|
|
|
|
Questions about ASP.NET should be posted in the ASP.NET[^] forum, regardless of what language they're written in (ASP.NET has more to do with a class library that works the same for any source language than a particular language).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
hi, i am new to C#.
I have a problem in using threads.
In my application i have two forms ( formA and formB )
In formA, there is a method "display" to display ( creating an object of formB and calling its show method )the formB.
and there is thread in formA, which monitors an integer variable continuosly, and when ever it set to 1, it calls the display method.
and there is a button in formA, upon clicking calls the same display method.
Clicking the button in formA , causes formB to load without any problem
But the same display method called by the thread in formA, doen't display the formB ( form "not responding" is coming in the text of formB ).
Can any one help me out in solving this problem ?
M.V.Ravikumar.
|
|
|
|
|
You have to execute your display method in the main UI Thread to avoid such problems.
This can be achieved by using the Invoke or BeginInvoke method of your FormA.
www.troschuetz.de
|
|
|
|
|
Thank you for your response.
It solved my problem.
M.V.Ravikumar
|
|
|
|
|
I want to break the API function (waitcommevent)
where I'm waiting data which i expect to receive.
the waitcommevent function is operating in a thread.
after a specific time if there's no data comes i make
thread.abort() methode to exit the thread.
but the waitcommevent is still hanging up the com
so when i try to close the com i can't.
so first I want to break the waitcommevent but i can't.
th1 = new Thread(new ThreadStart (loop));
timer1.Enabled = true ;
th1.Start() ;
void loop ()
{
while (true)
{
err = WaitCommEvent (handle,this.evPtr,IntPtr.Zero);
if (err==false)
{
error = Marshal.GetLastWin32Error() ;
if (error == ERROR_IO_PENDING) MessageBox.Show("ERROR_IO_PENDING"); else MessageBox.Show(error.ToString()) ;
}
else
{
this.getMask = (uint) Marshal.ReadInt32(this.evPtr);
if ( (getMask&1) == 1 )
{
err = ReadFile(handle,byt,1,out h,IntPtr.Zero) ;
MessageBox.Show(error.ToString());
MessageBox.Show("first byte:"+byt[0].ToString());
MessageBox.Show("Second byte:"+byt[1].ToString());
}
}
}
}
private void timer1_Tick(object sender, System.EventArgs e)
{
bool error = CancelIo(handle) ;
MessageBox.Show("Cancel is :"+error.ToString());
th1.Abort();
error = CloseHandle(handle) ;
MessageBox.Show("Handle closed is :"+error.ToString()) ;
}
|
|
|
|
|
can i transmit text from navigate of axwebBrowser to textbox?
|
|
|
|
|
Yes, but you have to create an interop assembly for MSHTML. If you installed VS.NET, the Microsoft.mshtml.dll assembly should already be present. If not, just run:
tlbimp.exe /out:Interop.MSHTML.dll MSHTML.dll You must get a reference to the IHTMLDocument2 interface. Handle the WebBrowser control's OnNavigationComplete (something like that - don't remember exactly right off-hand) and in that handler cast the AxWebBrowser 's Document property to IHTMLDocument2 . From there you can enumerate the elements or find the element with the ID you want, then set its value property (since it's an <input type="text"> element).
There are some articles about this here on CodeProject. A search[^] on "WebBrowser IHTMLDocument2" yields several good articles.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
hi
thanks for your reply.
i have a textbox that cannt chang selected font and forcolor of text in it and i want insert image to it.thus i use from html and show it in webbrowser and then i want transmit content of webbrowser to a textbox in another form.
textBox.selectedtext=<html<ui+textbox.selectedtext+ ui="">/HTML>.
.....
please tell me
can i do this work?how?
please suggest a realated sample.
|
|
|
|
|
That's terribly inefficient. The RichTextBox already supports all that - changing the selected font, etc.
As I mentioned before (and you continue to waste performance and memory on such a large solution using the WebBrowser control), you enumerate the IHTMLElement s from the IHTMLDocument2.all collection. When you find the elements you want, concat the text:
string str = string.Empty;
foreach (IHTMLElement2 elem in doc.all)
{
IHTMLInputElement input = elem as IHTMLInputElement;
if (elem != null) str += input.value;
} This is untested, but should give you an idea of how to concat text from text boxes. You should refer to the MSHTML reference to know how else to do things. Anything you can do in scripting you can do with MSHTML and more.
Read the MSHTML Reference[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
i want opendialog .i need name of file only no directory of it in filename.
how i do?
|
|
|
|
|
Take a look at the Path class which provides some methods to deal with path strings. Think the GetFileName or the GetFileNameWithoutExtension method should do the job.
www.troschuetz.de
|
|
|
|
|
|
i have to use textbox.becouse i want transmit content of this textbox to another textbox in another form.
|
|
|
|
|
i have to use textbox.becouse i want transmit content of this textbox to another textbox in another form.
i think that i should use from html but i dont know how?
|
|
|
|
|
The TextBox control doesn't support different fonts in the same TextBox. It's all one font or nothing. You can't change the font of a selection in a TextBox. Also, a TextBox control doesn't know how anything about HTML...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
We've a component that uses "osql.exe" to run an installation script and get a bunch of datbase objects (tables, triggers, stored proc...etc) installed on SQL Server. Is there something we can use with Oracle and MySQL to perform this same task? Thanks.
Norman Fung
|
|
|
|
|
They both have their own command-line applications. MySQL's is simply mysql.exe, but I don't know what Oracle's is. I would suggest either looking it up with google or find an Oracle newsgroup.
Might I recommend a better alternative, though? Nothing gaurantees that those command shells will be resolvable (in fact, IIRC, mysql.exe is not - it's in a directory that is not in the PATH env. var.). A better way might be to use a connection to their master databases (might have different names for each major database, but for SQL Server it is called "master") and then use whatever IDbCommand implementations that are appropriate for the database you're accessing (like SqlCommand , OleDbCommand , etc.) to build database objects. This is a pretty typical solution and doesn't rely upon command shells that may or may not exist.
Another scenario is if you're building database objects on a remote machine. The local machine may not the database installed so the command shell won't be present anywhere on the local machine.
For this reason, we use the method I outlined to build and update SQL Server databases, which should work just fine with any other RDBMS.
Microsoft MVP, Visual C#
My Articles
|
|
|
|