I am very new in outlook 2007 add in project.
I would like to know the event name when I select the start time in calendar of outlook (as below code that I tried for event). Thanks in advance.
namespace OutlookAddIn1
{
public partial class ThisAddIn
{
private Outlook.Explorer currentExplorer = null;
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
currentExplorer = this.Application.ActiveExplorer();
currentExplorer.SelectionChange += new Outlook.ExplorerEvents_10_SelectionChangeEventHandler(CurrentExplorer_Event);
}
private void CurrentExplorer_Event()
{
Outlook.MAPIFolder selectedFolder = this.Application.ActiveExplorer().CurrentFolder;
String expMessage = "Your current folder is " + selectedFolder.Name + ".\n";
String itemMessage = "Item is unknown.";
try
{
expMessage = expMessage + itemMessage;
}
catch (Exception ex)
{
expMessage = ex.Message;
}
// MessageBox.Show(expMessage);
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
}
#region VSTO generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InternalStartup()
{
this.Startup += new System.EventHandler(ThisAddIn_Startup);
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
}
#endregion
}
}
I am not sure what this has to do with ASP.Net... Your C# or VB.Net addin can use the Explorer.SelectionChange event. Explorer object can be retrieved from Application.ActiveEXplorer
When the event fires, read the Explorer.CurrentView property, check if it is an instance of the the CalendarView object and use the CalendarView.SelectedStartTime and SelectedEndTime properties.
i have a static string in static class, its getting value from desktop application,
on asp.net i have to check that its null or have value, if it has value , i want to
show it on label (on aspx page) , i have put a backgroud worker in global.asax,
public static BackgroundWorker worker = new BackgroundWorker();
public static int ID = 0;
// public static List<Person> personList = new List<Person>();
public static string personList;
public static bool stopWorker = false;
void Application_Start(object sender, EventArgs e)
{
worker.DoWork += new DoWorkEventHandler(DoWork);
worker.WorkerReportsProgress = true;
worker.WorkerSupportsCancellation = true;
worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(WorkerCompleted);
// Calling the DoWork Method Asynchronously
worker.RunWorkerAsync();
private static void DoWork(object sender, DoWorkEventArgs e)
{
//foreach (Person p in personList)
//{
personList = Class1.GetDataFromDesktop;
//}
}
its checking value time to time, but i am unable to show the response on label which is on aspx page
, what to do, is there any other process or i can do it using global.asax
Please tell me why does the following work fine in WinForms/WPF and not in ASP.Net.
We have a class library targeted for .Net 3.5. It has an interop referenced (generated from TLB).
public class MyClass
{
public delegate void ChangedEventHandler(string newStatus);
public event ChangedEventHandler Changed;
private ComObject objCom = new ComObject();
public void Init()
{
//Com events.
objCom.AvailabilityChanged += objCom_AvailabilityChanged;
//Start session to the h/w device.
//When finished, AvailabilityChanged event is fired with new h/w status.
objCom.StartSession("DeviceName");
}
void objCom_AvailabilityChanged(ComStatus status)
{
//Fired when session is started.
Changed(status.ToString());
}
}
And then i have a WinForms/WPF application (targeted for .Net 4.5) that creates a new instance of MyClass, subscribes to the Changed event and calls Init().
This works perfectly.
I'm trying to do the same in ASP.Net web forms application. The Init() method is being called, but the objCom_AvailabilityChanged event in MyClass is never fired.
public partial class WebForm1 : System.Web.UI.Page
{
private MyClass test = new MyClass();
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
test.Changed += test_Changed;
test.Init();
}
void test_Changed(string newStatus)
{
TextBox1.Text = newStatus;
}
}
Please explain what am i doing wrong.
Thanks a lot!
I have a server application written in WCF using asynchronous callbacks, and a webforms application in ASP.NET.
All of the communication is fine between the 2 applications, I can call the exposed functions in the server via the web application, and the server can send callbacks to the web application, however sometimes the functions within the callback work, and other times, they don't.
For example, I would like a login button on the web app to send a username and password to the server, the server checks this against the database, and if the login information is correct, it should send a callback, which opens a new page in the web app.
Here is the relevant server code:
public void Login(String username, String password)
{
//DoCheckAgainstDatabase(username, password);
ICallback callback = OperationContext.Current.GetCallbackChannel<ICallback>();
callback.LoginSuccess();
}
and the web application code:
private InstanceContext _instanceContext;
private ServiceClient _service;
public CallbackHandler MyCallbackHandler = new CallbackHandler();
protected void Page_Load(object sender, EventArgs e)
{
_instanceContext = new InstanceContext(MyCallbackHandler);
_backEnd = new ServiceClient(_instanceContext, "NetTcpBinding_IAU", "net.tcp://localhost/MyService/Service");
_backEnd.Open();
MyCallbackHandler.LoginSucceeded += OnLoginSucceeded;
}
protected void LoginButton_Click(object sender, EventArgs e)
{
_backEnd.Login(UsernameTextBox.Text, PasswordTextBox.Text);
}
private void OnLoginSucceeded(object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "OpenClientWindow", "window.open('Client.aspx','_self');", true);
}
I can put in breakpoints, and see that everything is working fine, it's just that the code 'ScriptManager.RegisterStartupScript...' does not execute properly all the time.
Could this be something to do with threading? Could anyone suggest a way to fix this please?
Thanks in advance!
David
It occurs to me that it's possible your page life cycle may be ending - or at least getting to the Render stage, which is where the start up script would be written to the output - before the callback is called.
Is it possible to call your service synchronously, and not proceed out of LoginButton_Click until the service call returns?
I think you are missing script tag - wrap your window.oppen with it, like
ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "OpenClientWindow", "<script>window.open('Client.aspx','_self');</script>", true);
Thank you Ann L. for guidance on this. I have added a ManualResetEvent, and then in the button click method, I wait until I have received the callback, then proceed with opening the new page:
private InstanceContext _instanceContext;
private ServiceClient _service;
public CallbackHandler MyCallbackHandler = new CallbackHandler();
private ManualResetEvent _resetEvent = new ManualResetEvent(false);
protected void Page_Load(object sender, EventArgs e)
{
_instanceContext = new InstanceContext(MyCallbackHandler);
_backEnd = new ServiceClient(_instanceContext, "NetTcpBinding_IAU", "net.tcp://localhost/MyService/Service");
_backEnd.Open();
MyCallbackHandler.LoginSucceeded += OnLoginSucceeded;
}
protected void LoginButton_Click(object sender, EventArgs e)
{
_backEnd.Login(UsernameTextBox.Text, PasswordTextBox.Text);
_resetEvent.WaitOne();
ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "OpenClientWindow", "window.open('Client.aspx','_self');", true);
}
private void OnLoginSucceeded(object sender, EventArgs e)
{
_resetEvent.Set();
}
I'm extending a web control. I need to call server methods on every event fired by the control instead of javascript.
public partial class MyTextBox : RadTextBox, IScriptControl
{
public MyTextBox()
{
Attributes.Add("onBlur", "handleLostFocus();");
Attributes.Add("runat", "server");
}
public void handleLostFocus()
{
MyObject obj = new MyObject();
obj.someproperty = this.Text; //or somehow get the user entered text.
MyService1 service = new MyService1();
service.sendRequest(obj);
}
}
As I said in my comment, TextBox will post by default if AutoPostBack = "True", however, you need to handle your event. Supposing your TextBox is named TextBox1:
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
string str = TextBox1.Text;
}
Get rid of handleLostFocus() or have it be the handler for your TextBox control.
Good luck mate.