Subscribe: Hannes Preishuber
http://weblogs.asp.net/hpreishuber/Rss.aspx
Added By: Feedage Forager Feedage Grade B rated
Language: English
Tags:
background color  background  color csharpcode  color  csharpcode color  csharpcode  data  margin csharpcode  net  system 
Rate this Feed
Rate this feedRate this feedRate this feedRate this feedRate this feed
Rate this feed 1 starRate this feed 2 starRate this feed 3 starRate this feed 4 starRate this feed 5 star

Comments (0)

Feed Details and Statistics Feed Statistics
Preview: Hannes Preishuber

Hannes Preishuber



ON ERROR RESUME NEXT!



 



German jQuery conference call for papers

Sat, 01 Aug 2015 18:07:00 GMT

ppedv is proud to announce in cooperation with the jQuery foundation the German jQuery conference in Berlin. The conference is for the DACH region (Deutschland, Austria, Switzerland). Sessions are in German and English

We are looking for speakers for the whole eco system around jQuery. For us jQuery is the base for nearly every JavaScript Framework.

You are expert in jQuery, jQuery mobile, Angular, React, Bootstrap some other UX Framework. Your are welcome

Send your short proposal to events@ppedv.de as soon as possible.

We are also hosting full day tutorials.

(image)

Hope to see you in Berlin, Dec. 9-10.




free pop3 for Windows 2012 Server

Mon, 06 May 2013 05:34:00 GMT

Our team develops tools for Windows Server. Fifteen years ago we started with a pop3 queuing (popConnect) tool. We offer a free extender for the IIS SMTP Service to support pop3.·         You want to provide emails from any source (e.g. IIS, SharePoint, …) for POP3 retrieval by any mail client (e.g. Outlook, Thunderbird, …). ·         You used the Microsoft POP3 Service in Windows Server 2003 and miss the feature after migrating to Windows Server 2012 or Windows Server 2008. ·         You are looking for a free POP3 Server. ·         You don’t need or want all the capabilities of Microsoft Exchange and you want a small, performant solution to provide your emails. Visendo SMTP Extender is a full POP3 server that runs as a Windows service, originally developed for Windows Server 2008, as a substitute for the missing POP3 service there. It monitors an e-mail drop folder, such as IIS "mailroot\drop", and provides the e-mails to clients for collection via the POP3 protocol. About 5 years ago, Visendo Software, a department of ppedv AG, released the first version of Visendo SMTP Extender. Since then, we continually developed and improved the software: ·         better RFC compliance ·         higher stability ·         easier to install, configure and use ·         mailbox overview with mail size and count for more detailed information check the complete changelog and version history: http://support.visendo.com/default.aspx?g=posts&t=686 product website: http://www.visendo.com/smtpextender.aspx There are several guides, also from third parties, to help you installing and configuring your email environment. How to configure IIS SMTP Server in combination with Visendo SMTP Extender: http://www.visendo.com/download/visendosmtpextender/docs/VisendoSmtpExtender_manual_en.pdf How to configure Sharepoint in combination with Visendo SMTP Extender: http://en.hugon.ws/articles/sharepoint-2010/installing-and-configuring-smtp-and-pop3-services-for-sharepoint-2010/ * http://mosshowto.blogspot.de/2010/05/installing-smtp-pop3-sharepoint-2010.html * *this was with an older version of SMTP Extender. You can use the admin interface instead of editing the config file manually now. You can download Visendo SMTP Extender here: Community Edition (free): http://www.visendo.com/VisendoDownloads.aspx?id=42 Plus Edition (99 € / 30 day trial): http://www.visendo.com/VisendoDownloads.aspx?id=52 Differences: the Plus Edition supports unlimited client connections, parsing of multiple custom destination header fields and other advanced features. Please let us know if you like SMTP Extender. Get in touch by Email: support[at]ppedv.deComments are disabled, cause of blog spamming. [...]



Update Visendo SMTP Extender Update

Sat, 02 Oct 2010 08:39:00 GMT

Our team from ppedv (credits to Cosmin) have released the new edtion based on your feedback.

Visendo STMP Extender, extends the SMTP Server from Windows 2008 (and R2) to the POP3 protocol. So in fact you get the possibilty to pull mails via POP3 from your IIS 7 based webservers.  

Download and Info

http://blogs.visendo.com/post/2010/10/01/Visendo-SMTP-Extender-version-RTM.aspx

Its free, costs nothing.

The Visendo team develops: Fax Server (also for ISDN), Anti Spam and pop3 pulling (popconnect). The SMTP Extender is a spin of from that team and code base. Enjoy it.




302: this blog will be closed

Wed, 26 May 2010 17:39:00 GMT

After nearly 7 years I will discontinue blogging on this site. My resources are limited. You can reach my German blog which is used to support my customers. Looking back to a long an interesting journey

ASP.NET by ScottGu

That was the reason to attend this site and support Microsoft as much as I can. For that I was honored as ASP.NET MVP- thanks again. Meet Scoot several times. Great guy!

Forums

I have left NNTP forums a few years ago and now Microsoft closed it- It was my idea ;-)

AJAX

Was the wrong way- JQuery won the game

IIS7

That is really a great plattform and the IIS team rules. I am sad that is so silent around that topic.

ASP.NET after 2.0

Is no longer my world. I love ASP.NET and ASP.NET Server controls. I hate the discussion about how to follow the holy rules of MVC. Microsoft have dropped the goal to bring ASP.NET to #1 and accepted PHP is it.

Facebook & Twittering

Microblogging takes over a part of the blogging business. Shorter faster cheaper- or as SteveB mentioned - do more with less.

Google

Google is taking over the web. I am using Bing every time as I can but Google have more options. Sorry Microsoft you will loose that game.

Apple

That is not the biggest problem of Microsoft. the Ixxx takes over a small part but big money of the market, but the customers are not strongly linked. New wave new hype- Game over Apple.

Silverlight

My new home. I can reuse a lot of my skills and love the possibilitys. Silverligth will passing WPF-and strike Flash

Windows phone 7

Also my skills fit. I just will use it for fun. I am not really satisfied about what I have heard from MIX. Guys from Redmond, I am sad to say you have been the best Smartphone OS and lost everything.

The ADO vNext Story

That will be the next mystic point. WCF, REST, JSON, ATOM and now OData. Nothing about SQL commands. LINQ, ORM is also not the final solution for multilayered disconnected async scenarios. Personally I prefere the OData idea and dislike the Swiss Army Knife (German Eierlegende Wollmilchsau) WCF.

I am still in INETA Speakers board and I am glad to come to your user group. In all other cases you can hire me over ppedv AG.

Good by and have good live.




Adhoc testing of .NET RIA Services

Thu, 22 Oct 2009 05:57:52 GMT

Suddenly my Silverlight 3 application breaks during development process. Cause I have installed Visual Studio 2010 a few hours before, I was sure: must be something with 2010. After uninstall and reinstall SP1 everything worked fine, except .NET RIA services :-(

So back to structured trouble shoothing. What is the first point, the database- SQL Profiler shows no requests. Second point is Entity model. Till now I do not know any point to interactive test a model. Next point is the RIA Service. But how to call a RIA Service in Browser? I took fiddler to figure it out

http://localhost:51240/ClientBin/DataService.axd/test3-Web-DomainService1/GetCustomers

  • Server and Port: here ASP.NET Web Dev Server
  • ClientBin directory
  • dataservice.axd – you can find the registration of the handler in web.config
  • test3 – Application name
  • Web – cause service is in website and not in Silverligth project
  • DomainService1 – is the name of the domain service class which I selected
  • GetCustomers – is the name of the domain service method in the service class to retrieve the customers- here I call northwind DB

Then error message. Reason was admin (natural enemy of developer) locked out a IP from SQL port. Nothing related with VS 2010.




Open SQL Port for specific IP by ASP.NET Website

Wed, 26 Aug 2009 08:35:42 GMT

We run a public SQL Server on Windows Server 2008 and had a lot of dictionary attacks in the past. To prevent that, do following

1) disable sa user

2) enable Windows Firewall, set a inbound rule ( here named sql) and lock the port 1433, then add the external IP’s ( scope tab) which needs access from extern

 

(image)

Now you are save. New problem is, what happens when you have dynamic IP address on client and need access by SQL Manager or Visual Studio Server Manager. Take really long time to solve that problem. My goal was to establish a website, where you click a button and your IP is in the firewall.

1) create a user account on server which have exactly the fitting rights for netsh and firewall. Group User should be enough

2) create in IIS7 a application pool which this account. Impersonation doesn't work. Even start a process which a specific user account. This comes later.

3) create a Web application in IIS7 (also subdirectory possible) with app pool from 2)

4) create a command file name sqlip.cmd to set the ips in the firewall and test it on server if it works

netsh advfirewall firewall set rule name="sql" new remoteip=194.x.x.x,195.x.x.x,%1

5) create aspx page where you call cmd.exe with processtart. This was complicated and I have to do some workarounds eg. can not call the cmd directly. Have to open cmd.exe and send input to the process.

 

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim ps As System.Diagnostics.ProcessStartInfo = New System.Diagnostics.ProcessStartInfo("cmd.exe")
        ps.UseShellExecute = False
        ps.RedirectStandardOutput = True
        ps.RedirectStandardInput = True
        ps.RedirectStandardError = True
        Dim proc As System.Diagnostics.Process = System.Diagnostics.Process.Start(ps)
        Dim strm As System.IO.StreamReader = System.IO.File.OpenText(Server.MapPath("sqlip.cmd"))
        Dim sout As System.IO.StreamReader = proc.StandardOutput
        Dim sIn As System.IO.StreamWriter = proc.StandardInput
        Dim zeile As String
        While (strm.Peek() > 0)
            zeile = Replace(strm.ReadLine(), "%1", Request.UserHostAddress)
            sIn.WriteLine(zeile)
        End While
        sIn.WriteLine("EXIT")
        strm.Close()
End Sub

That sample only works for one dynamic ip. If you want more make some list where the Ip’s stored and add the list with netsh.




ASP.NET have left the track?

Sat, 22 Aug 2009 14:25:31 GMT

I am a fan of ASP.NET. I have teached hundreds of peoples, written some books, have been MVP for that topic. But now I have doubts. Today I try to build a special kind of user navigation experience. I learn ASP.NET have stopped to grow since version 2.0. ASP.NET 2.0 is the most productive web (even UI ) development technology in the market. But today's needs have changed. For my site I need a Menu control which popup horizontal. Menu control is the same since 2.0 and can only vertical. Some tricks based on ASP.NET CSS friendly control adapters does not work cause the development of CSS adapters was stopped in early 2007 (or truly give over to community which is the same). My need is a second static tabbed main menu without dynamic popup. This can be set by MaximumDynamicDisplayLevels to 0. CSS Adapters ignore this setting so I cant use it.

Instead of investing in UI better new controls, extending parts like AJAX Toolkit Controlextender, ASP.NET team develops fancy stuff. Project Volta or MVC Framework.  The ASP.NET MVC framework is: rewrite everything from scratch with less productivity and less controls. It looks like the early ASP times. How much people in percent needs MVC? How much needs nicer UI?

Sorry Microsoft I don't understand your goals at this point.

And it seems 4.0 will not do it better.




Silverlight Twitter Client with authentication

Thu, 30 Jul 2009 13:00:14 GMT

Its not easy to access a cross domain RSS feed. But it is nearly impossible to do same with authentication. HTTP Client stack and HTTP browser stack in Silverlight 3 and beyond does not support authentication. All tricks with manipulating HTTP header throw some not implemented exception. For my workaround I use a browser bridge built with Jscript. First i created a twitter account and closed the RSS feed to “followers”. Which have the effect that when accessing the RSS with browser Login Dialog is poping up. Next step is I add a AJAX Scriptmanager into the aspx page which is hosting Silverlight Plugin. Then i write the JScript code to  access the Twitter url. The magic is inside the HTTP Header. You have to implement “username:password” base64 encoded in authorization header tag. This sample creates from SilverlightInsi:password the base64 string. The encoding will be done later in Silverlight application. function anmelden(user) { // base 64 =U2lsdmVybGlnaHRJbnNpOnBhc3N3b3Jk var w = new Sys.Net.WebRequest(); w.set_url("http://twitter.com/statuses/friends_timeline/61248865.rss"); w.set_httpVerb("GET"); w.get_headers()["Authorization"] = "Basic " + user; w.add_completed(WennFertig); w.invoke(); } Now we code a button click in silverlight. With htmlpage helper we can invoke the Jscript RSS download function “anmelden” and pass the security credentials. Private Sub Button_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Dim user As String = "SilverlightInsi" Dim pwd As String = "password" Dim daten() As Byte = System.Text.Encoding.UTF8.GetBytes((user + ":" + pwd)) HtmlPage.Window.Invoke("anmelden", Convert.ToBase64String(daten)) When the data have arrived, Jscript calls function “WennFertig” in ASPX page. There you get the response data (the rss). To bring back the data to Silverligth application we call a managed code function calles Twitterloaded. To get the reference you have to find the Plugin (ID of object). And take the content and use the “sl” object. We will see the why and how a few lines later function WennFertig(executor, eventArgs) { if (executor.get_responseAvailable()) { var SL = document.getElementById("sl1"); SL.Content.sl.TwitterLoaded(executor.get_responseData()); } } Now we are back in manged code of Silverligth. I register the plug for Jscript as “sl”. This allows Jscript in general to access the insides of the plugin Public Sub New() InitializeComponent() HtmlPage.RegisterScriptableObject("sl", Me) End Sub We need a managed function which can be called from outside by Jscript. That is declarted by ScriptableMember Attribut. So function “Twitterloaded” can now be invoked from outside. The next lines are quit tricky. I use the Syndication class from Silverlight. This saves a lot of coding, cause I d not need to creat data classes or extra lists. _ Public Sub TwitterLoaded(ByVal daten As String) Dim sr As StringReader = New StringReader(daten) Dim xr As XmlReader = XmlReader.Create(sr) Dim feed As SyndicationFeed = SyndicationFeed.Load(xr) datagrid1.ItemsSource = feed.Items.ToList End Sub One issue is left. The SyndicationItem is not a flat datatype. So I have to take in care in XAML binding to refer to right property, like Title.Text. The datagrid gets templatecolumns. [...]



Silverlight 3 Visual Studio 2008 Designer Preview

Sat, 18 Jul 2009 16:29:42 GMT

Documentation says that Design Preview in Silverlight 3 Tools for Visual Studio 2008 is away. The preview with Silverlight 2 was only read only and sucks. OK is bad but no preview is even worse. When you right click a XAML file there is still context menu “view Designer”.

So why? Cause designer is still here- but hidden!

move mouse to bottom of XAML editor.

(image)

No mousecoursor is a double arrow which can be drag by mouse down to upper direction.

(image)

Now click relaod and ready.

After closing file- designer setting is away. Perhaps i find a solution somewhere in template settings.




Silverlight 3 Beta to RTW changes

Sat, 11 Jul 2009 08:31:00 GMT

It is very important that your applications are ready for Silverlight 3. If you have developed with the Beta bits you have to do a lot of changes to get ready for RTW. There exists a document changes.docx which I can not find at the moment. For that reason I decided to make a copy public on my private server.

If you run a Silverlight 2 application no action is necessary. The SL3 plugin can host SL2 applications. So there are no breaking changes between 2 and 3!

There are a set of bugs fixed in SL 3 related to SL 2. For compatibility reasons Silverlight plugin detects and change to quirks mode running SL 2 applications in a bug friendly mode.

[Update]thanks to Tim Heuer: link is http://msdn.microsoft.com/en-us/library/cc645049(VS.95).aspx. Saves traffic on my server ;-)

[/Update]




ADO.NET Dataservice This collection already contains an address with scheme http PartII

Thu, 22 Jan 2009 20:04:39 GMT

You may have searched for This collection already contains an address with scheme http.  There can be at most one address per scheme in this collection. Parameter name: item I have written some time ago a blog post which have a workaround with removing http headers in iis. Now I found in documentation prefixfilters which allow the use of ado.net dataservice with multiple host headers on website. There must be some setting in web.config like .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } No I run in second problem. IIS specified authentication schemes 'Basic, Anonymous', but the binding only supports specification of exactly one authentication scheme. OK- it’s easy to change that in IIS. But what's about authenticated access e.g. for Frontpage server extensions? Still looking…. Next I got a error message Request Error The server encountered an error processing the request. See server logs for more details aha-mhh- which logs- where, WTF? I found a sloution to display the full error within browser. You have to add in service metadata. _ Public Class EventDataService1 .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } Now I have the next error: bei System.Data.Metadata.Edm.MetadataArtifactLoaderCompositeResource.LoadResources(String assemblyName, String resourceName, ICollection`1 uriRegistry, MetadataArtifactAssemblyResolver resolver) bei System.Data.Metadata.Edm.MetadataArtifactLoaderCompositeResource.CreateResourceLoader(String path, ExtensionCheck extensionCheck, String validExtension, ICollection`1 uriRegistry, MetadataArtifactAssemblyResolver resolver) bei System.Data.Metadata.Edm.MetadataArtifactLoader.Create(String path, ExtensionCheck extensionCheck, String validExtension, ICollection`1 uriRegistry, MetadataArtifactAssemblyResolver resolver) bei System.Data.EntityClient.EntityConnection.SplitPaths(String paths) bei System.Data.EntityClient.EntityConnection.GetMetadataWorkspace(Boolean initializeAllCollections) bei System.Data.Objects.ObjectContext.RetrieveMetadataWorkspaceFromConnection() bei System.Data.Objects.ObjectContext..ctor(EntityConnection connection, Boolean isConnectionConstructor) bei System.Data.Objects.Object[...]



Silverlight 2.0 Compression Rate

Fri, 02 Jan 2009 14:11:00 GMT

After a short discussion in silverlight forums with a guy who have only 19kb line, I checked out compression for XAP files. A XAP is a zipped package of DLL’s and resources. With winrar installed you can open by context menu from Visual Studio Explorer the xap (clientbin). It contains files like

(image)

The size of the package in this case is 750 KB. I unzipped the content and compressed it with Winrar again and- surprise- surprise, package size is now 547 KB. A reduction more than 35%. Only rename the zip back to xap.

I will investigate a little bit, how to automate that within the build process.




B# and Silverlight Isolated Storage

Sat, 29 Nov 2008 09:02:54 GMT

I am a VB developer. As most of expert coder are using C# I must step forward. B# is the language which can be written by VB guys and make it readable for C# gurus. Today's topic is the data store of Silverlight on client side- isolated storage. Isolated Storage is a concept from .NET. It allows to store information on a per application base, like cookies. Major differences are much more space and more security. There exists several ways to store data. First option is like ASP.NET appsettings. Private appSettings As IsolatedStorageSettings = _ IsolatedStorageSettings.ApplicationSettings '; .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } Based on a Key Object collection you can store simple data like strings or also complex data like generic lists. Dim liste As New List(Of tasks)'; ..... appSettings.Add("daten", liste) '; appSettings.Add("test", New Date)'; appSettings.Add("hannesKey", "Hannes Preishuber")'; .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } Reading is as simple ausgabe.Text = appSettings("hannesKey")'; .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } Isolated storage can also be used like a file system to store images or xaml. Code is written with B#. Using mystore As IsolatedStorageFile = _ IsolatedStorageFile.GetUserStoreForApplication()'; .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { c[...]



Input Validation with Silverlight

Sun, 23 Nov 2008 10:23:00 GMT

I miss ASP.NET. With the 2.0 Microsoft had the world best technology for creating applications of all kind. Small or large, ASP.NET 2.0 have features for all. Now several years later we have Silverlight 2 (no 2.0) and should be good as ASP.NET 2.0!? I don't think so- Silverlight have some great advantages but even more missing features. And some of them essential and important. For me user input validation is one of them. To get the right data from user in correct format is a huge challenge and costs a lot of development time. ASP.NET have rich and easy validator controls to do the job. Silverlight have not. But Input validation must done, so how? I will show you my approach. First of all, where to validate? Database Data Layer UI Layer User Interface Nowhere I don't like typing things several times. I hate to make data access and type field name 10 times in table, properties and UI. I like the drag and drop stuff and get declaration of where and how my data comes. (no dataset at all ;-)).  Silverlight doesn't have that by design and by architecture. The design part comes from Microsoft they have not enough resources to implement every feature within some weeks. Second problem with data validation comes from loosely connected systems. The user interface is fare fare away from database. Sometimes thousands of km/ miles are between them. Proxy server, hubs, switches even different protocols and ports. So from that view it doesn't make sense to get data schema each time from table and reuse it in UI. Input validation rules must be declared physical narrow to user interface. The closest thing I can imaging is within the same memory address space. The practice Cause of disliking typing code I use a ADO.NET Entity model and a ADO.NET Dataservice to get the data. Visual Studio 2008 creates a proxy class (reference.vb) for the Silverlight project. Database is northwind with table customer. The goal is a input dialog. Phone number is limited to 20 characters. Error is shown as tooltip (zu lange). Textfield is marked as read. Tabbing out will do the validation. First of all I create the rule set. I do that in the created proxy class (reference.vb) and check the length and throw an exception.Public Property Phone() As String Get Return Me._Phone End Get Set If Len(value) > 20 Then Throw New Exception("zu lange") End If Me.OnPhoneChanging(value) Me._Phone = value Me.OnPhoneChanged() End Set End Property .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } Not the best solution. If somebody is updating service reference, your code will be overwritten. The databinding in the Textbox must have twoway binding and two additional attributes set. That is necessary to get a special event in error case (exception) which will defined in next step .csharpcode, .csharpcode pre { font-size: small; [...]



Rownumber in Silverlight Datagrid or Listbox

Tue, 18 Nov 2008 19:42:20 GMT

My next sample uses a converter to show a line number within a datalist. I am not really satisfied with the solution, perhaps I will find in future a better way. But the concept is quite interesting and it works. First we need a TextBlock to display the row number. The content is controlled by databinding. Unique data (here [daten]) is needed as parameter for later converting.  The converter needs to be declared as resource. xmlns:c="clr-namespace:SilverlightApplication1test"> .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } The converter is implemented as class which uses a special interface. The trick is to get a reference to the original data. As you can see I get a reference to application.current and cast it to the class, which is named page17. Page17 is the xaml page. There I can find my listbox named lstfields and get all items. The items are from type listboxdaten and have a property [daten]. If you compare the property with the value from the converter you get the index of the datarow. Public Class rowNumberConverter Implements IValueConverter Public Function Convert(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.Convert Dim mypage As page17 = CType(CType(Application.Current, App).RootVisual, page17) For i = 0 To mypage.lstFields.Items.Count - 1 If CType(mypage.lstFields.Items(i), Listboxdaten).daten = value Then Return i + 1 End If Next Return "nan" 'should never happen End Function Public Function ConvertBack(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.ConvertBack Throw New NotImplementedException() End Function End Class .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { [...]



get ID inside a Silverlight Datagrid when Button clicked

Sat, 15 Nov 2008 10:22:07 GMT

This blog pots describes a datagrid and a encapsulated custom button for each row. I want to show two methods how to get information about the underlaying data of the row. I use a ado.net data service and a entity datamodel, which is not part of the article, to get the data. Database is good old northwind and table is customer. When use clicks on button messagebox comes up with some information about the row. First the xaml code .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } The databinding to the tag attribute is necessary for my first trick Private Sub Button_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) MessageBox.Show(CType(e.OriginalSource, Button).Tag) End Sub .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } Easy or? Do you like it more complex, than following code gives you the select row as number Private Sub Button_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Dim datenliste As List(Of ServiceReference1.Customers) datenliste = DataGrid1.ItemsSource 'automatischer cast Dim datenButton As Object = CType(e.OriginalSource, Button).DataContext() MessageBox.Show(datenliste.IndexOf(datenButton)) End Sub .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .att[...]



Silverlight Multiselect Listbox

Fri, 07 Nov 2008 14:44:33 GMT

The Listbox control of Silverlight 2 have no multi selection. Datagrid have! I want to show how to build a Listbox with Checkboxes and iterate at the end through all items an see if they are checked. Seams to be easy!? But isn't.  You can not access the content of the datatemplate. One solution is to use visualtreehelper to iterate through all controls of controltree. That is quite complkicated cause e.g a checkbox is a composition of Textblock and Rectangle. I show the databinding way which is quite cool First I have to generate a class where all data is in and a additional field for the checked value. Imports System.ComponentModel Imports System.Collections.ObjectModel Public Class Listboxdaten Implements INotifyPropertyChanged Private _checked As Boolean Public Property checked() As Boolean Get Return _checked End Get Set(ByVal value As Boolean) _checked = value OnPropertyChanged("checked") End Set End Property Private _daten As String Public Property daten() As String Get Return _daten End Get Set(ByVal value As String) _daten = value OnPropertyChanged("daten") End Set End Property Public Event PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged Protected Sub OnPropertyChanged(ByVal name As String) RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(name)) End Sub End Class .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } I dont like the typing, but that is another story. Now comes the cool part  in XAML. The trick is to do a two way binding. .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { co[...]



Silverlight and ADO.NET Dataservices RTW changes

Tue, 14 Oct 2008 21:13:38 GMT

Till the days of Silverlight RC0 (so yesterday ;-)) we had to generate the proxy class for ado.net dataservice service by hand like:

dataSvcUtil.exe /out:dsProxy.vb /language:VB /uri:http://localhost:64184/eventsDataService1.svc/

Surprisingly the final RTW of silverlight tools for visual studio have the feature to create the proxy by wizard. Everything you have to do, is to select from menu “add service reference” and to press discover button

(image)

You get in your project a little bit more then before. The logic is in reference.vb and looks exactly the same as with command line tool.

(image)

A instance of the entity is then created with code like that

 Dim srv As New ServiceReference1.eventsEntities

The edmx from the silverlight project is in my case not editable with designer. In the source model, which exists in the website, it works fine.




ADO.NET Dataservices: Fancy Error Part II

Mon, 13 Oct 2008 09:13:55 GMT

Today my first Silverlight 2 application goes live. It is a customer feedback app for the ADC 08 conference. After successfully installed and tested a few hours everything went well. But then data was not show. on direct call of ado.net dataservice vcs in browser following error comes up

Die Datei oder Assembly App_Web_znszzsfo, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null oder eine Abhängigkeit davon wurde nicht gefunden. Das System kann die angegebene Datei nicht finden

The rest of the asp.net site works well.

As I was used to from earlier experience   with ADO.NET dataservices on IIS 6 the error message is not what it seams. I tryed restart of IIS, delete temp ASP.NET compiled files of website. Nothing helped.

The original reason was a change of the server ip address by admin. Workaround was to delete temp files from root folder.




ADO.NET Dataservices:This collection already contains an address with scheme http

Fri, 10 Oct 2008 17:52:44 GMT

I have deployed a Silverlight 2 application which uses ADO.NET Dataservices to a IIS 6.

Problem #1: you see nothing in Browser

register MIME Type in IIS and restart IIS

Problem #2: no data is sown in Silverlight

In my case it was a 2nd hostheader entry in the Web site. Remove the 2nd hostheader, restart the service and call the ADO.NET Dataservice (svc) directly in Browser