hi can I get the lync contacts and them status in a listview with C#? I want to get all users from ad to a listview in asp.net web application and control wheater a user is online or offline.
Yes you can. Check the following links to integrate lync in asp.net applications:
Lync integration:
http://sharpsplash.wordpress.com/2012/08/03/integrate-microsoft-lync-into-a-asp-net-web-application/
Show MS Lync presence status:
http://htmlpresencecontrols.codeplex.com/
If Carlos' links do go dead, here is the TL;DR. This Javascript taps into the NAME.dll in C:\Program Files\MicrosoftOffice\Office14:
<script>
$(function() {
//hide the ooui if the user scrolls.
(window).scroll(function() {
HideOOUI();
});
$('#lyncspan').hover(function() {
//show ooui on mouseover event
ShowOOUI();
}, function() {
//hide ooui on mouseout event
HideOOUI();
});
});
var sipUri = "your.contact#your.domain.com";
var nameCtrl = new ActiveXObject('Name.NameCtrl.1');
if (nameCtrl.PresenceEnabled)
{
nameCtrl.OnStatusChange = onStatusChange;
nameCtrl.GetStatus(sipUri, "lyncspan");
}
function onStatusChange(name, status, id)
{
//In a real world application you would display
//a status icon instead of an alert
alert(name + ", " + status + ", " + id);
}
function ShowOOUI()
{
nameCtrl.ShowOOUI(sipUri, 0, 15, 15);
}
function HideOOUI()
{
nameCtrl.HideOOUI();
}
</script>
<span id="lyncspan" style="border-style: solid">Your Contact<span>
Related
Ok so when you click a hyper link in my web app it just adds to the URL to the end. like so http://localhost:8080/http//:www.youtube.com. I'm using visual studio .net to make web rest APIs. The web app lunches on IIS express 10. the home page URL is http://localhost:8080/index.html.
user gets links to click
links are populated
error after user clicks link
error page
$.ajax(
{
url: "/api/Link/1",
type: "GET",
dataType: "json",
success: function (data)
{
var array = $.parseJSON(data);
$("a").remove();
for(var i=0;i<array.length;i++)
{
$("body").append("" + array[i].name + "");
}
},
error: function ()
{
}
});
//rest api called
[HttpGet]
public string GetLinkList(int id)
{
string json = "[";
using (StreamReader infile = new StreamReader("C: /Users/jkarp/Documents/visual studio 2015/Projects/Protal/Protal/App_Data/linkObjs.txt"))
{
while (!infile.EndOfStream)
json += infile.ReadLine()+",";
}
if(json.Length > 1)
{
json = json.Remove(json.Length - 1);
return json + "]";
}
return "[]";
}
Your link is malformed:
http//:www.youtube.com
The colon : is in the wrong place, it should be:
http://www.youtube.com
The link will be contained in your datasource linkObjs.txt, fix it there and the problem should go away.
I'm building a webshop in C# (MVC). Now I want to change the number of items that is shown in the cart-icon (at the layout-page). I've found this code and want to customize it to my page.
$(function () {
// Document.ready -> link up remove event handler
$("##product.ArtNumber").click(function () {
// Get the id from the link
var itemToAdd = $(this).attr("data-id");
if (itemToAdd != '') {
// Perform the ajax post
$.post("/ShoppingCart/RemoveFromCart", { "id": recordToDelete },
function (data) {
// Successful requests get here
// Update the page elements
if (data.ItemCount == 0) {
$('#row-' + data.DeleteId).fadeOut('slow');
} else {
$('#item-count-' + data.DeleteId).text(data.ItemCount);
}
$('#cart-total').text(data.CartTotal);
$('#update-message').text(data.Message);
$('#cart-status').text('Cart (' + data.CartCount + ')');
});
}
});
});
Now I have a question about " $.post("/ShoppingCart/RemoveFromCart" "
In my case I don't want to switch to another page when you click the button - but add an item to the cart (at the layout-page). What can I write instead of "post"? As I've understand this is used when you want to open a new HTML-page?
The $.post is shorthand of jQuery.post. http://api.jquery.com/jquery.post/
It is an ajax call, and occurs in the background asynchronously. You are expected to have an endpoint that will handle the HTTP post on the server. Ideally this will update the server with the cart information such that it is available later if the client disconnects or closes their browser.
In my case I don't want to switch to another page when you click the button
I failed to actually answer your question directly. It will not take you to a different page or navigate away from the current page. You can actually open a new tab and paste that URL into the browser and see that it returns JSON.
i have a login page in fancy box and on click of login i want the secure pages open in the new tab
and uses this code
// on code at btnlogin_click
FormsAuthentication.RedirectFromLoginPage(loginID, false);
string redirectTo = GetResPath("/webPages/Default.aspx");
ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "add2", "parent.jQuery.redirTo='" + redirectTo + "'; parent.jQuery.fancybox.close();", true);
//on aspx page
<script type="text/javascript">
$(document).ready(function () {
$('[id*=logn_btn_new]').fancybox({
'width': 480,
'height': 280,
'padding': 10,
'margin': 10,
'hideOnOverlayClick': false,
'scrolling': 'no',
'autoScale': false,
'transitionIn': 'none',
'transitionOut': 'none',
'type': 'iframe',
'onClosed': function () {
try {
if ($.redirTo != null && $.redirTo.length > 0) {
var pop = window.open($.redirTo, '_newtab');
if (pop == null) {
alert("Please allow popups.");
}
}
}
catch (err) {
alert(err);
}
}
});
});
</script>
and redirTo is hidden fielld.
i am not able to open page in new tab can anybody help?
This is a difficult one, as it is something that is controlled by the user's web browser settings.
The method that you are using is specific to FireFox and will indeed open a new tab. But this can still be overridden by the user's settings.
However to get the same effect in other browsers here is an article for IE Open a new tab in IE through Javascript
It is worth considering why you need to do this. Users may be confused if you open a new tab / window without informing them. Is it possible to not open a new window and keep everything in the same page? Then you know that people logically will have the same results to an extent.
I hope this helps!
I am using the following code in my facebook application. The when loading the application in facebook has no problem in chrome/firefox/ie8. When it runs in IE9 it is reporting that OAuthException has been thrown.
public string GetFacebookId() {
if (!FacebookWebContext.Current.IsAuthorized())
return string.Empty;
var client = new FacebookWebClient();
dynamic me = client.Get("me");
return me.id;
}
(OAuthException) An active access token must be used to query
information about the current user.
any suggestions would be appreciated.
thanks.
EDIT:
window.fbAsyncInit = function () {
FB.init({
appId: '#(Facebook.FacebookApplication.Current.AppId)', // App ID
//channelURL: '//facebook.thefarmdigital.com.au/moccona/premium/FacebookChannel/', // Channel File
status: true, // check login status
cookie: true, // enable cookies to allow the server to access the session
oauth: true, // enable OAuth 2.0
xfbml: true // parse XFBML
});
FB.Canvas.setAutoGrow();
};
$(function () {
$('#custom_login').click(function () {
FB.getLoginStatus(function (response) {
if (response.authResponse) {
//should never get here as controller will pass to logged in page
} else {
FB.login(function (response) {
if (response.authResponse) {
window.location = '#(Request.Url.AbsoluteUri.Replace(Request.Url.PathAndQuery, ""))' + $('#custom_login').attr('href');
} else {
window.location = '#(Request.Url.AbsoluteUri.Replace(Request.Url.PathAndQuery, ""))' + $('#custom_login').attr('dataFail');
}
}, { scope: 'publish_stream' });
}
});
return false;
});
});
I'm not familiar with FB's C# SDK, but judging from the code you gave, it does not seem that you are doing any user authentication with FB. It might be that it works in Chrome and Firefox only because you are somehow already logged into your FB app in those browsers.
Hi i want notifications to popup if the need arises. I am using an asp.net timer which checks if a new message has arrived. The problem i am getting is that the jquery notification does not show up. I am guessing this is something to do with the update panel. Because when i tried calling it from pageload it worked fine. Here is my code;
protected void updateTimer_OnTick(object sender, EventArgs e)
{
Cache Cache = new Cache();
users = Cache.getUserDetailsByUserID(Convert.ToInt32(Page.User.Identity.Name));
if (users._bNewNotification)
{
List<UserNotification> listUserNotification = null;
listUserNotification = Cache.getLatestNotifcationsByUserID(Convert.ToInt32(Page.User.Identity.Name));
foreach (UserNotification userNotification in listUserNotification)
{
StringBuilder jquery2 = new StringBuilder();
jquery2.AppendLine("$.extend($.gritter.options, {");
jquery2.AppendLine("position: 'bottom-left',");
jquery2.AppendLine("fade_in_speed: 100,");
jquery2.AppendLine("fade_out_speed: 100,");
jquery2.AppendLine("time: 3000");
jquery2.AppendLine("});");
Page.ClientScript.RegisterStartupScript(typeof(Page), Guid.NewGuid().ToString(), jquery2.ToString(), true);
StringBuilder jquery1 = new StringBuilder();
jquery1.AppendLine(" var unique_id = $.gritter.add({");
jquery1.AppendLine(" title: 'This is a sticky notice!',");
jquery1.AppendLine(" text: '" + userNotification._NotificationType + "',");
jquery1.AppendLine(" image: 'http://s3.amazonaws.com/twitter_production/profile_images/132499022/myface_bigger.jpg',");
jquery1.AppendLine(" sticky: true,");
jquery1.AppendLine(" time: '',");
jquery1.AppendLine(" class_name: 'my-sticky-class'");
jquery1.AppendLine(" });");
Page.ClientScript.RegisterStartupScript(typeof(Page), Guid.NewGuid().ToString(), jquery1.ToString(), true);
}
users._bNewNotification = false;
users.UpdateNewNotification();
Cache.RemoveUserProfileCacheByUserID(users._USERS_ID);
}
}
Can someone help me figure out what it is i am doing wrong, thanks
Your approach won't work. When the browser gets your page it disconnects, so your server-side C# timer event handler code will have no browser to talk to.
You need to do something like implement polling on the web page in client-side JavaScript. e.g.
<script>
$(document).ready(function(){
window.setInterval(function(){
$.get('path/to/GetNotifications.aspx', function(data){
// data contains text from GetNotifications.aspx
// it could be JSON, XML, CSV... it's up to you
// do something with it here...
})
},5000 /*5s*/)
})
</script>