29 Aralık 2016 Perşembe

Writing javascript in *.cs file

There are two "Asp.NET methods" for writing script blocks in the server side.

1) RegisterStartupScript
2) RegisterClientScriptBlock

If RegisterStartupScript method is used,  the script element is written just before closing the form element. 
This means that every html controls have been defined before the script block. Therefore the script objects can point these reference without any problem. 

When RegisterClientScriptBlock method is used, the script block is written before the definitions of the html objects in an aspx file. Therefore the statements in the scripts should be written in a function that can be called just after the html objects are created. 

Let's make it clear with an example.

Think we have a Label control(Label1) and we want it to show the client date.

When we use RegisterClientScriptBlock like the figure below, Label1 does not show us the date. 


Infact while the page is loading, an error is occured. The error can be seen by opening developer tools of Chrome.  The error is : "Uncaught TypeError: Cannot set property 'innerHTML' of null" which means it is not possible to set the property of a control which hasn't been created yet. Labl1 has not been created yet.


If you press the error link it will show you the code that can not be run properly.

Let's write the same script by using RegisterStartupScript.


Label1's innerHTML can be assigned by the date function.
Because the script block is written after HTML controls are defined.




Using javascript within ASP.NET

As you can see in the pages of this blog that was published before javascript codes can be written in HTML pages and can be used with the HTML objects. Itis also possible to use javascript codes by adding them to ASP.NET controls. There are different ways of adding them into the ASP.NET controls.

1) You can add them to the attributes of ASP.NET by writing to the server side file(*.cs file)
2) You can add them by writing to the client side file (*.aspx file)

In each way the javascript code should be associated with a client side event is bound to a ASP.NET control.

You can see each way below within an example. In ASP.NET a multiline textbox can not be limited with a max length by just using ASP.NET control attribute panel.


Although I set MaxLength as 15 as you can see below the TextBox1 control could not be limited with the length of 15.
In order to limit multiline textbox  you can add the client side attribute of maxLength by writing Asp.Net code in the Page_Load. Therefore while the page is loading this attribute is added to the control.


It is limited with the length of 15. Here is the result :
The second way is writing a script within the aspx file and calling it from a suitable client event. Here onkeyup event is used to call the script.


The result is same. Maximum 15 characters can be written in TextBox1 control.
It is also possible to call the javascript function by adding "onKeyUp" event to the attributes of TextBox1 from cs file as shown below.



TextBox1 has a maximum length of 15 again.



19 Aralık 2016 Pazartesi

Javascript 2 - getting values from text field

Javascript 2 - getting values from text field

The code written during record shows how can a function get the values from input fields. Shouldn't be considered as a completed code. It is lack of lots of controls.










18 Aralık 2016 Pazar

Javascript 1 - Writing a function

Javascript tutorial 1 : Writing a function

In order to develop dynamic web pages you need to use javascript. In the beginning you will find the basics of the language and after a few videos later I will show how it is possible to use javascript along with .NET. After that I am planning to present NodeJS application. Infact it is not a javascript framework however its many modules built in Javascript.

You will see writing the scripts among the html codes is really fun. I want to start from writing a basic function that can multiply 2 numbers that are stored in HTML's <ul>.  My aim is to create the below page. You can watch the video or just find the codes at the bottom of this page.









11 Aralık 2016 Pazar

Creating a Server by using Node.js

I will present in detail about Node.js. This page can be seen as a draft for creating a server task by using Node.js.

You can find the code below.

server.js file :
var http = require('http');
var host = '127.0.0.1';
var port = '1330';
var server= http.createServer(function(request,response) {
console.log("Coming request: "+request.url);
response.writeHead(200 , {'Content-type' : 'text/plain'});
response.end('Hello World!');
});

server.listen(port,host,function(){
  console.log('Listening port'+ ':' +host+':'+port);
});

You can start the server by typing "node server.js" into the command shell.



You can use Chrome's Postman extension as client that posts requests.


8 Aralık 2016 Perşembe

UI Design For Relational Inductive Learning Algorithm with JAVA

The study contains developing user interface for the learning algorithm
named RILA which is designed for relational databases. RILA algorithm developed
by adding new features on ILA and ILA2 which are inductive learning algorithms
developed before RILA algorithm. While the user interface is developed, showing of
the rules generated by RILA aimed to be understandable to the user. In addition, the
logs of the process of rule generation are showen to the user. In developmental stage,
the library which contains the graphical elements is used and platform-independent
programming language was chosen. The user interface is also has ability to connect
to multiple relational database. It is observed that; the software provides the
possibility of adding new modules in the future as of the design.

You can find the study by clicking here.

Some screen shots of the GUI are below.








7 Aralık 2016 Çarşamba

FINDING FEED FORWARD LOOPS IN A GIVEN NETWORK

The program is developed in JAVA. NetBeans is selected as the IDE. Program takes one argument as text file. Text file contains the network data and during execution from console it should be given to the program. e.g. fflcount network_file.txt
Program has three classes.
1) Neighbour
2) Vertex
3) fflcount


Vertex and Neighbour classes is used for creating linked list.

You can find the report and the codes by clicking the links below :