воскресенье, 31 января 2010 г.

Звуковые сигналы BIOS.

Доброго времени суток.

Как Вам уже известно, почти сразу после включения компьютера через встроенный в корпус динамик слышен короткий сигнал, генерируемый bios, который говорит, что: "Все нормально парень (или девушка, но это реже)! Можешь работать дальше!". Но иногда, вместо этого, приятного слуху писка раздается целая трель непонятных сигналов и как серпом по ... сами знаете по чему (интересно, а в случае с девушкой как же). Короче, компьютер не включается. Что делать? Выбрасывайте системный блок в окно и идите пить пиво. Ну а если серьезно, то знайте, что Вы очень может быть попали на бабки, но может такого и не быть. Зачастую, достаточно включить компьютер по новой и все. Если это не помогло, тогда внимательно слушайте сигнал и запомните, сколько коротких и сколько длинных гудков прозвучало. Если Вам медведь на ухо наступил, то это Ваши проблемы, но если со слухом все в порядке и Вы можете отличить короткий сигнал от длинного, то сверьтесь с таблицами в конце статьи. Там написаны возможные неисправности в зависимости от подаваемых bios сигналов. Обратите внимание на слово "возможные". Дело в том, что программа POST - это не мощная программа для тестирования железа. Она тоже может ошибаться.

Так что же делать после того, как Вы расшифровали ошибку? Попробуйте вынуть плату (процессор, планку памяти), вызвавшую ее, и вставить назад, или просто проверьте, хорошо ли она "сидит" в разъеме. Только делайте это аккуратно, предварительно отключив кабель питания от сети и сняв статическое напряжение с пальцев рук (и ног) коснувшись рамы корпуса. Если проблемы со CMOS, то специальным джампером на системной плате обнулите настройки (или просто вытащите на несколько секунд батарейку). Если неполадки с клавиатурой, то проверьте соединение оной с системным блоком, целостность кабеля. Если проблемы с блоком питания, проверьте, а подключили ли Вы его к материнской плате, а если подключили, то правильно ли это сделали. Кстати, у меня лично был случай, когда я неправильно подключил разъем мыши к материнской плате (наоборот), компьютер не включался и никаких сигналов не было!

Но если Вам ничего не помогло, то, к сожалению, придется нерабочий девайс поменять, хотя остается надежда на то, что BIOS Вашей материнской платы просто не может работать с ним. В таком случае необходимо его, BIOS, перешить. Нo это уже тема для отдельной статьи.

Итак, таблицы звуковых сигналов BIOS от AMI и AWARD. Один короткий сигнал обоих фирм означает, что все ОК. В таблицах длинный сигнал обозначен буковкой "д", а короткий - "к".

AMI

сигналы

Возможная неисправность

- *

Накрылся блок питания


Ошибка четности ОЗУ


Ошибка в первых 64 кБ ОЗУ


Неисправность системного таймера


Неисправность CPU (процессора)


Накрылся контроллер клавиатуры


Накрылась системная плата


Проблемы с памятью видеокарты


Ошибка контрольной суммы BIOS

10к

Невозможна запись в CMOS

11к

Неисправен кэш, расположенный на системной плате

1д+2к

Проблемы с видеокартой

1д+3к

То же

1д+8к

Не подключен монитор


AWARD

сигналы

Возможная неисправность


Мелкие ошибки **


Ошибка контроллера клавиатуры

1д+1к

Ошибки в ОЗУ

1д+2к

Ошибка видеокарта

1д+3к

Ошибка инициализации клавиатуры

1д+9к

Ошибка при чтении из ПЗУ

к, повторяющийся

Неисправен блок питания

д, повторяющийся

Проблемы с ОЗУ

непрерывный

Неисправен блок питания


* - отсутствие какого-либо звукового сигнала.

** - в большинстве случаев это проблемы в CMOS Setup или с системной платой.

Ну вот и все. Дай бог Вам никогда не услышать эти сигналы :)

четверг, 28 января 2010 г.

__doPostBack function

hi every one Today i am going to talk about __doPostBack function.because there is some confusion in using _dopostback

You can see this __doPostBack function in your asp.net generated HTML code.
The function takes two arguments are:

1) eventTarget

2) eventArgument

1) EventTarget contains the ID of the control that causes the postback

eventArgument contains any additional data associated with the control.


When a page is posted back to the server ASP .NET inspects __EVENTTARGET and __EVENTARGUMENT values and this way it can decide which of the controls caused the page to be postedback and what is the event that has to be handled.
In any asp.net page the two hidden fields, “__EVENTTARGET” and “__EVENTARGUMENT,” are automatically declared. The value of the eventTarget and eventArgument are stored in the hidden fields. The two hidden variables can be accessed from the code behind using the forms or params collection.

My Anaylsis(Aamir Hasan)

If we inspect the code of the __doPostBack function we can see that it first sets the values of two hidden fields created by ASP .NET named __EVENTTARGET and__EVENTARGUMENT with the two parameters passed to the function. After this the page is submitted back to the server.When a page is posted back to the server ASP .NET inspects__EVENTTARGET and __EVENTARGUMENT values and this way it can decide which of the controls caused the page to be postedback and what is the event that has to be handled.The ID of the control which causes the postback is stored in the __EVENTTARGET hidden field, so you can find the control which caused the postback.


<a id="LinkButton1" href="javascript:__doPostBack('LButton3','')">LinkButton</a>
You can see the fucntion call "__doPostBack('LButton3','')" in href and the argument passed for eventTarget is "LButton3" which is the id of the linkbutton control (EventSource)

Example

i am going to talk aamirhasan.aspx Page.

in aamirhasan.aspx Page

1) Add two hidden filed inside the form as given below

<input type ="hidden" name ="__EVENTTARGET" value ="">
<input type ="hidden" name ="__EVENTARGUMENT" value ="">

2) Add javascript under the Head tag as given below

<script>
function __doPostBack(eventTarget, eventArgument) {
document.Form1.__EVENTTARGET.value = eventTarget;
document.Form1.__EVENTARGUMENT.value = eventArgument;
document.Form1.submit();
}
</script>

3) add two control given below

<a id="LButton3" href="javascript:__doPostBack('Button2','')">LinkButton</a>

<asp:button id="Button2" runat="server" onclick="Button2_Click" text="Button">

4) add function in your cs page

protected void Button2_Click(object sender, EventArgs e)
{
Response.Write("Welcome to Student Academic Blog");
}

So this is how you can use _doPostBack

Enjoy it

Note:ultimately a postback will only fire, if there is a control in the page with a property "autopostback=true".

суббота, 23 января 2010 г.

Using the Open File Dialog Window in WPF





In many applications, there are certain tasks that you perform frequently. Some of those tasks include opening files, saving files, printing files, and so on. Because a lot of these tasks do not vary among applications and require some level of OS-level hacking, Windows provides built-in functionality and a consistent UI for performing these tasks for you. You commonly use them in the form of dialog windows.
In this tutorial, I will explain how to use one such dialog window known as Open File. The Open File dialog window is what you see when you, for example, go to File | Open in most applications:
[ the Open File dialog window in Vista ]
To maintain consistency, it is better for you to use the same Open File dialog window in your applications to provide open file functionality, and you'll learn how to do that and more in this tutorial. The final section of this tutorial is dedicated to address a WPF issue that displays the wrong version of the Open File dialog window in Vista.
Getting Started
Instead of having you spend time creating your own application, I have provided a very simple application consisting of a button to which you will add some code to for testing/displaying your dialog window:
[ your sample application ]
So, first, download and extract the source files used for creating the sample application shown above:
[ your recently extracted files ]
Once you have extracted the files, open this project using Visual Studio or the free Visual C# Express. I'll be using Visual C# Express for this tutorial.
With your project now opened, open Window1.xaml.cs. You will see the following code displayed:
using System;
using System.IO;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Navigation;
using Microsoft.Win32;
namespace DialogTest1
{
public partial class Window1
{
public Window1()
{
this.InitializeComponent();
// Insert code required on object creation below this point.


}






private void WindowLauncher(object sender, RoutedEventArgs e)



{






}





}





}



The WindowLauncher event handler method is what gets called when the button in your application is pressed. In the following sections, you'll add code to your WindowLauncher method to display your Open File dialog window.
OpenFileDialog
The Open File dialog window provides an Explorer-like view for navigating through your files and selecting a file for you to open. What is returned after your journey through the Open File dialog window is the path to the file you selected.
To use this dialog window, you use the OpenFileDialog class. Copy and paste the following two lines into your WindowLauncher method:
private void WindowLauncher(object sender, RoutedEventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.ShowDialog();


}



Once you have added the above two lines to your WindowLauncher method, run your application by press F5. Click on your Launch Window button to see your Open File dialog appear.
If you look at our code, we declare an OpenFileDialog object called ofd. We then call ofd's ShowDialog() method:
ofd.ShowDialog();
When you use the ShowDialog() method, you are launching a window that is modal. A modal window borrows focus from your entire application to itself. You will be unable to access the window that spawned the modal window until your modal window is closed.
Opening a File
One of the primary functions of your Open File dialog window is to return the path of the file you selected. To retrieve the path of the selected file, replace the code inside your WindowLauncher with the following code:
private void WindowLauncher(object sender, RoutedEventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
if (ofd.ShowDialog() == true)
{
string filePath = ofd.FileName;
string safeFilePath = ofd.SafeFileName;


}





}



This time, if you select a file by double-clicking on it or by selecting it and pressing your Open button, the file's name is stored in two variables called filePath and safeFilePath. Before we get to the file names itself, notice how I check to make sure that a file has been specified for opening:
if (ofd.ShowDialog() == true)
{
string filePath = ofd.FileName;
string safeFilePath = ofd.SafeFileName;


}



Your ShowDialog() method returns an object of type bool? which is a nullable boolean. A nullable boolean returns a value that is true, false, and a third type that is null. If you select a file for Open, your ShowDialog method returns true. If you click Cancel or close your Open File dialog window, the value is false.
Since we are interested in dealing with the result of a file that is specified for opening, we only check the true property. Now, let's look at our filePath and safeFilePath variables:
string filePath = ofd.FileName;
string safeFilePath = ofd.SafeFileName;
The filePath variable gets its data by accessing ofd's FileName property, and safeFilePath gets its data by accessing ofd's SafeFileName property. Your FileName is the full path to your file plust your file's name and extension. The SafeFileName returns just the name of your file and its extension. The path is not returned.
For example, let's say you decide to open a file located in your C:\Windows path called regedit:
[ opening a file using the Open File dialog window ]
When you select that file for opening, your FileName will be C:\Windows\regedit.exe, and your SafeFileName will be regedit.exe. Depending on what you are doing, you will need to decide whether you want to use FileName or SafeFileName.
Opening Multiple Files
You can tailor your Open File dialog window to actually select multiple files if needed. The following code shows you how:
private void WindowLauncher(object sender, RoutedEventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Multiselect = true;
if (ofd.ShowDialog() == true)
{
string[] filePath = ofd.FileNames;
string[] safeFilePath = ofd.SafeFileNames;


}





}



There are only two main changes when you want to select multiple files. The first change is that you need to set your OpenFileDialog object's Multiselect property to true:
ofd.Multiselect = true;
With Multiselect set to true, you are now able to select multiple files. With multiple files, though, you cannot store the data in a single string variable like you did for the single file case earlier. This brings us to our next change where the values returned by your dialog window are stored in an array:
string[] filePath = ofd.FileNames;
string[] safeFilePath = ofd.SafeFileNames;
Notice that both filePath and safeFilePath now store an array of strings. Also, instead of using FileName and SafeFileName to store the full path and file name, you use the plural form - FileNames and SafeFileNames.
Filtering by File Extensions
Another cool Open File dialog window is learning how to filter the files you see based on the file extension. Right now, your application doesn't filter based on any extensions:
[ currently you are not filtering by extensions ]
To filter by file extensions, you use your OpenFileDialog's aptly named Filter property:
private void WindowLauncher(object sender, RoutedEventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Multiselect = true;
ofd.Filter = "Data Sources (*.txt, *.xml)|*.txt*;*.xml|All Files|*.*";
if (ofd.ShowDialog() == true)
{
string[] filePath = ofd.FileNames;
string[] safeFilePath = ofd.SafeFileNames;


}





}



When you run your application this time, notice that you can now filter based on Data Sources and All Files:
[ you now filter by Files of type ]
To specify your own filters, you need to provide the filter's description and the extension. The syntax you use to you specify the filter is a little weird, so let's look at the approach I used to specify my Data Sources and All Files filters:
ofd.Filter = "Data Sources (*.txt, *.xml)|*.txt*;*.xml|All Files|*.*";
The basic format is Description 1|*.ext1;*.ext2|Description 2|*.ext1;*.ext2" You separate the description and the extension(s) using the | character. If you are using multiple extensions, you separate each of them using a semicolon, and note that each extension must be preceded by the * wildcard character.
Fixing OpenFileDialog under Windows Vista
If you take a close look at the OpenFileDialog under Windows Vista, you'll find that it looks out of place with its old-school style and low quality icons:
[ the old-school Open File dialog window ]
This is actually not a feature. To display the proper OpenFileDialog in Windows Vista and earlier versions, one solution is to call the WinForms version of OpenFileDialog. To do that, first you will need to add a reference to System.Windows.Forms. From your Solution Explorer in Visual Studio / C# Express, right click on the References folder and select Add Reference:
[ we need to add a reference to your project ]
After you have selected the Add Reference menu item, the Add Reference window will appear. From this window, make sure the .NET tab is selected. Scroll down until you find the System.Windows.Forms Component Name:
[ let's add the System.Windows.Forms namespace ]
Select System.Windows.Forms and press OK to add the reference to this component and to close the Add Reference window.
Now that your reference has been added, we need to add a new using statement to get our C# file to use components stored in System.Windows.Forms. In your Window1.xaml.cs file (which should be open anyway), add the System.Windows.Forms namespace to your list of using statements:
using System;
using System.IO;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Navigation;
using Microsoft.Win32;
using System.Windows.Forms;
After you have added your new using statement, press F6 to build your application. You will notice that you now receive a few errors:
[ two errors now appear because of an incompatibility ]
The errors are caused because the OpenFileDialog class exists in both your Microsoft.Win32 namespace as well as you newly added System.Windows.Forms namespace. To resolve this problem, right click on each instance of the OpenFileDialog class in your code, select Resolve, and from the next menu, select System.Windows.Forms.OpenFileDialog:
[ select your OpenFileDialog window ]
You'll need to repeat the above process for each OpenFileDialog instance that exists in your code. For example, this is how my code now looks like:
private void WindowLauncher(object sender, RoutedEventArgs e)
{
System.Windows.Forms.OpenFileDialog ofd = newSystem.Windows.Forms.OpenFileDialog();
ofd.Multiselect = true;
ofd.Filter = "Data Sources (*.txt, *.xml)|*.txt*;*.xml|All Files|*.*";
if (ofd.ShowDialog() == true)
{
string[] filePath = ofd.FileNames;
string[] safeFilePath = ofd.SafeFileNames;


}





}



Notice that OpenFileDialog object declaration and initialization explicitly maps out the path through System.Windows.Forms to avoid the ambiguity that exists with the similar OpenFileDialog that exists in Microsoft.Win32.
When you build your application again, you'll run into another error. This time, our earlier code where we check if our dialog window returns a true for opening a file no longer works. In the WinForms version of OpenFileDialog, you'll need to explicitly select your dialog window's OK button as having been pressed, and you can do that via the WinForms DialogResult enum:
private void WindowLauncher(object sender, RoutedEventArgs e)
{
System.Windows.Forms.OpenFileDialog ofd = newSystem.Windows.Forms.OpenFileDialog();
ofd.Multiselect = true;
ofd.Filter = "Data Sources (*.txt, *.xml)|*.txt*;*.xml|All Files|*.*";
if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
string[] filePath = ofd.FileNames;
string[] safeFilePath = ofd.SafeFileNames;


}





}



Notice that instead of checking if ShowDialog returns true, I check to see if it was the OK button that was used to close the dialog window. If you build and run your application again, you will not receive any errors. If you are running a non-Vista version of Windows, you'll display the usual Open File dialog window, but if you are running Vista, you will see the more native Open File dialog window instead:
[ the correct, proper version of the Open File dialog window ]
Why Bother Using the Win32 Version?
A valid question would be to ask why the Win32 version should even be used when dealing with dialog windows. The main reason is that all dialog windows including the Windows.Forms versions, internally call the same lower level implementation of the dialog window. Ideally, it should not matter whether you create your OpenFileDialog object using the Win32 namespace or the Windows.Forms namespace. The end result should be that the best version of the dialog window that can be displayed by your OS should be displayed.
I believe that future versions of WPF will fix this inconsistency, so hopefully you will not have to create this workaround using Windows.Forms inside a WPF application in the future. A fix would automatically cause any WPF applications that use the currently-incorrect Win32 calls to automatically display the new version. If you are willing to risk the wait, you can use the default Win32 approach and automatically display the new windows when the fix is made. If you want to provide a good UI now, you can make the call to the dialog window using Windows.Forms as described in this page.

пятница, 22 января 2010 г.

Entity Framework Resources

I came across a few great resources on Entity Framework recently.

Check out the tutorial and the projects here: http://weblogs.asp.net/zeeshanhirani/archive/2008/12/18/my-christmas-present-to-the-entity-framework-community.aspx. This contains a very informative learning guide that includes many mapping examples, LINQ to Entities query examples, databases that are used in the examples, and much more.

The tutorial is based on the Entity Framework version 1 (introduced in .NET Framework 3.5 SP1).

Also, download this fantastic tool that lets you dynamically query Entity Framework models using LINQ:http://www.linqpad.net/EntityFramework.aspx (works with EF v1). The .NET Framework 4 Beta 2 version of the tool is available here: http://www.linqpad.net/beta.aspx.