Posts

Showing posts from April, 2012

IIS, DLL and Exhange

my ADMIN tried to run my asp sln ang got a problem - our dll's are x86 and the IIS is x64. so you can always change it to x86 but not if ur using exchange, he likes only x64 in an IIS. so he found a sln and i want to record the links for future generations: http://blogs.msdn.com/b/rakkimk/archive/2007/11/03/iis7-running-32-bit-and-64-bit-asp-net-versions-at-the-same-time-on-different-worker-processes.aspx http://blogs.msdn.com/b/vijaysk/archive/2009/03/06/iis-7-tip-2-you-can-now-run-32-bit-and-64-bit-applications-on-the-same-server.aspx http://www.mosmar.com.au/chris-blog/2011/3/15/taking-care-of-bitness-or-how-to-run-a-32-bit-app-with-owa-2.html

Catch Enter on ASP Form example

1st thing u must know - u cant do it directly like any other controls.OnTextChange therefor the good lord gave us JS! put this script on: <script language ="javascript" type ="text/javascript">       document.onkeypress = function () {             document.getElementById( "Hidden1" ).value= "false" ;              if (window.event.keyCode==13){           alert(window.event.keyCode); //to see that it works              }       document.getElementById( "Hidden1" ).value= "true" ;                  form1.submit();            } </ script > This on the aspx page : < input id ="Hidden1" type ="hidden" runat ="server"/> and on the cs page: protected void Page_Load( object sender, EventArgs e) {     if (Hidden1.Value == "true" )          TextBox1.Text = "We Got an Enter to the Server Side" ;     else               

Access: Call a Func from another Form with example

the main points are: 1 - make the func public (daa but we forget) and "As Variant" 2 - actualy find the damn form and how to call the func when u have that u have it (double daa) and for the example call a func in a subform from the main form the func: Public Function Call_payment_date_AfterUpdate() As Variant        p ayment_date_AfterUpdate End Function from the main form (in a func o/c) Forms!ei_main_form![ei_purchase subsubform].Form.Call_payment_date_AfterUpdate from a stand alone form call a func in another form the func Public Function Call_Refresh_From_ei_main() As Variant     Me.Refresh End Function the call Forms!ei_main_form.Call_Refresh_From_ei_main

תקשורת על גבי רשת האינטרנט מאת ALEXSUH

כל התודות לאלכס מפורום תפוז שהשקיע בנו כ"כ, הכל מועתק ללא שינוי מה שאתה מדבר עליו נקרא פרוטוקול SOAP לתקשורת על גבי רשת האינטרנט. זה פרוטוקול מקובל בד"כ אם אתה שולט הן בצד השרת וצד הלקוח . סיומת ASMX מקובלת במימוש הפרוטוקול על גבי שרתי MISCROSOFT מסוג ASP.NET אך הפוטוקול אינו ייחודי ל MIcrosoft וניתן לשתמש בכל סיומת כל עוד עומדים בתקנים של הפרוטוקול. בעולם האמיתי לא תמיד ניתן לקבל שירות נוח של קליק וגמרנו ומדי פעם צריך לבצע קצת עבודה ע"מ לקבל את הנתונים. במקרה הנ"ל אין מדובר בשרות מסוג SOAP אלא בקובץ XML רגיל אשר מתעדכן אחת לכמה זמן (לדעתי פעמיים שלוש ביום) וניתן להורדה ישירה תוך שימוש בפרוטוקול HTTP רגיל. קצת רקע עוד מידע על לפרוטוקול SOAP http://www.w3schools.com/soap/default.asp פרוטוקול HTTP עליו פרוטוקול SOAP מבוסס http://he.wikipedia.org/wiki/Hypertext_Transfer_Pr... פרוטוקולים נוספים המבוססים על HTTP REST http://www.infoq.com/articles/rest-introduction XML-RPC (המיושן אך עדיין נפוץ בפינות נשכחות של האינטרנט) http://en.wikipedia.o

Ajax Image Asp example

1st we need a source to return a requested img, i'll use an ASP page like this (ASPX part doesnt matter, u may not touch it), lets call it ReturnPic.aspx protected void Page_Load( object sender, EventArgs e) {     System.Drawing. Image img = System.Drawing. Image .FromFile(          Request.QueryString[ "file" ].ToString());     //u have to use the system.drawing or ull get the we.ui.image     string ext = Path .GetExtension(Request.QueryString[ "file" ].ToString());     if (ext == "jpg" )        ext = "jpeg" ;    * MemoryStream ms = new MemoryStream ();     img.Save(ms, System.Drawing.Imaging.     ImageFormat .Jpeg);     ms.Close();     byte [] content = ms.ToArray();     Response.ContentType = "image/" + ext;     Response.BinaryWrite(content); } u can always use ImageConverter http://www.vcskicks.com/image-to-byte.php now here is my default page, i used 2 method to return the pic b

Linq Vs Mysql

the answer - mysql (and i guess any sql kind) is about 500-1000 times faster BUT, yes we have a HUGE but - this is only for the query time the SQL query himself from the DB. then we have transportation - there, the bigger the data requested is the more u might be better using Linq, AND we have a BUT here too - Linq depends on ur computer resources so... anyway on my job's machine i did a query from a table with 300K+ rows. when the answer was less than 100 rows the mysql was that fast. when i tried something with 60k+ rows and another with 250K rows the Linq became 60%+ faster. *!this does not include the initial query of all the 300K lines Soooo...   for me it means that if i am gonna query something alot it might be better a Linq or even 2 querys on something with 60K+ rows More: on 4K they r the same 20K Linq is faster by about 20%+ again my machine my router speed... my conclusion: *Linq is better when u query at least 3-5 times and more AND were talking about

DataSource a Linq(ed) DataTable example

if u ever tried to query with Linq a datatable and then assign it to a DataGridView (and other stuff i guess) then u might have noticed that the grid shows the properties of the DataRow(s). And if you tried to select the ItemArray, again a mess. Sooo... its so simple i laugh at myself but i must: var query =      from data in tblAllData.AsEnumerable()      where data.Field< DateTime >( "Start" ).Month == ( int )cmbMonths.SelectedValue      select data; if (query.Count() > 0)                     dgvMain.DataSource = query.CopyToDataTable(); TADA!

Winforms ComboBox Text & Value example

the really simple way, and goes for the rest of the winform controls you could also put a list of any class and choose 2 properties DataTable tblMonths = new DataTable(); tblMonths.Columns.Add( new DataColumn ( "Name" , typeof ( string ))); tblMonths.Columns.Add( new DataColumn ( "Value" , typeof ( int ))); for ( int i = 1; i <= 12; i++) {     string month = DateTimeFormatInfo .CurrentInfo.GetMonthName(i);     tblMonths.Rows.Add(     new object [] { month, i }); } cmbMonths.DataSource = tblMonths; cmbMonths.ValueMember = "Value" ; cmbMonths.DisplayMember = "Name" ; cmbMonths.SelectedValue = DateTime .Now.Month;

mysql Count the Distinct example

like: ari ari dani ari I want select like this: ari     3 dani  1 SELECT   my_column ,   COUNT (*) AS num FROM my_table GROUP BY  my_column ORDER BY COUNT (*) DESC thanks stack overflow

WinForms Bypass Cross Thread Update Error example

we can do 2 things the 1st, not everybody loves it (and i guess that in large slns  u should avoid it) is the CheckForIllegalCrossThreadCalls  prop:. public Form1() {     InitializeComponent();     Form1 .CheckForIllegalCrossThreadCalls = false ; }   private void button1_Click( object sender, EventArgs e) {      Thread t = new Thread ( new ThreadStart (target));      t.Start(); }   private void target() {      this .Text = "ddddd" ; } the other way is to use a delegate: delegate void SetTextCallback ( string text); private void SetText( string text) { // InvokeRequired required compares the thread ID of the // calling thread to the thread ID of the creating thread. // If these threads are different, it returns true.    if ( this .textBox1.InvokeRequired)    {       SetTextCallback d = new SetTextCallback (SetText);       this .Invoke(d, new object [] { text });    }    else    {        this .textBox1.Text

Ease of WebRequest example

this is and example of a generic method to execute POST WebRequests, and in this case login into a site, don't worry, the values are fake. the 1st part is a secondary example, how to call MakeWebRequest method itself, which is the main thing in this post. System.Collections.Specialized; - ns for NameValueCollection NameValueCollection parameters = new NameValueCollection (); parameters.Add( "textBox1" , "422" ); parameters.Add( "textBox2" , "gensearch" ); parameters.Add( "textBoxUserName" , "UserName" ); parameters.Add( "textBoxPassword" , "mode matchallpartial" ); string strRes = "" ; string url = " http://www.mysite.com/login.aspx\jsp\php\ect ." ; CookieContainer cookie = new CookieContainer (); MakeWebRequest(url, "POST" , ref cookie, parameters, ref strRes); //and strRes is our response, either h

Paralel Events example

So you wanna have 2 events running at the same time (parallel)? nope - they will run as a stack, we need , threads! so typically I would recommend using the TPL library but sometimes its not exactly what you need, and sometimes you work with .Net 3.5. If we just start new thread in WinForms we also get cross trread exception... - this is solved with delegates! Here is my code for 2 textboxes with doubleClick event to write to a 3rd textbox, 1st textbox by an event, the other textbox by a thread. note that the event are still in a stack although they get a different class. the threads should work without a class but this is a pattern for "heavier" work: public partial class Eventer : Form {      int id = 10;      public Eventer()     {            InitializeComponent();      }          private void txtEnter_DoubleClick( object sender, EventArgs e)     {          cWriter cw = new cWriter (id++);          cw.SendBack += new cWri

Ajax - the 3 simple ways example

the most easy way to do ajax, if you're developing with .Net, is to use the AjaxUpdatePanel. tp use it you must add a script manager to your page, preferred in you master page if you have one, and from there on all your standard logic and fields and whatever inside the Content Template < asp : ScriptManager ID ="ScriptManager1" runat ="server" > </ asp : ScriptManager > < asp : UpdatePanel ID ="uppContact" runat ="server" UpdateMode ="Conditional">     < ContentTemplate >        <!-- html tags -->       <% -- server tags -- %>     </ ContentTemplate > </ asp : UpdatePanel > most developers don't like the UpdatePanel and for good reasons: 1 - for it to trigger you need a server control that will trigger a post back 2 - it actually do a full postback, with a full page life cycle, and a full response, only in the client if "fakes" it to feel as onl