Tuesday 30 June 2015

textbox allow only characters javascript

textbox allow only characters javascript

button click event not firing in asp.net c#

button click event not firing in asp.net c#

This is type of issue many times occurs in asp.net. whenever button click is not execute first check your html
Is <form>   tag in page ?

Form tag must be 1 time only, otherwise your c# event is not execute.


button click event fire using javascript

button click event fire using javascript

special character not allowed validation in javascript

special character not allowed validation in javascript

Email Validation in javascript

Email Validation in javascript

remaining characters counter javascript

remaining characters counter javascript

start date greater than end date validation in javascript

start date greater than end date validation in javascript
end date greater than start date javascript validation

how to write javascript code in c#

how to write javascript code in c#

set placeholder using javascript

set placeholder using javascript

Bind Gridview from XML File

Bind Gridview from XML File

Friday 26 June 2015

open url in new window using javascript

if you want to open page or new url  in new tab or new window using javascript code then you have to use window object in your javascript code.

wimdow.open() method use to open url in new window.


Other Articles - Step by step solution

------------------------------------------------------------------------
three tier architecture in asp.net
how to connect MS access in asp.net
how to access website in LAN
------------------------------------------------------------------------

It's solution for



=> Open URL in new tab using javascript        
=> Open URL in same tab using javascript
=> Open URL in new window using javascript
=> Open URL in new window with custom size using javascript

var MyUrl = "http://problemaspdotnet.blogspot.in";

window.open(MyUrl);

window.open(MyUrl, "_blank");

window.open(MyUrl, "_parent");

window.open(MyUrl, "_self");

window.open(MyUrl, "_top");

window.open(MyUrl, "_blank", "toolbar=yes, scrollbars=yes, resizable=yes, top=200, left=100, width=150, height=150");

Tuesday 16 June 2015

How to bind CheckBoxList from database

Here I will explain how to bind CheckBoxList from database
and in previous I posted this articles

How to bind DropdownList from database
how to access asp.net website in LAN
how to create database from script file

Checkboxlist is group of checkbox. You can check multiple item in CheckBoxList control in asp.net.
If item list is too more than use the DropDownList .

If you want to bind CheckBoxList from database table then you write following code in your website.
First , Your .aspx page should be like this

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title> How to bind CheckBoxList from database </title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:CheckBoxList ID="chkType" runat="server">
            </asp:CheckBoxList>
      
    </div>
    </form>
</body>
</html>



And your code behind like this

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;
using System.Data.SqlClient;
using System.Configuration;

public partial class _Default : System.Web.UI.Page
{
    SqlConnection cn;
    DataTable dt;
    protected void Page_Load(object sender, EventArgs e)
    {
        cn = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
        if (!IsPostBack)
        {
            BindCheckBoxList();
        }

    }
    public void BindCheckBoxList()
    {
        SqlCommand cmd = new SqlCommand("SELECT id,Name from tbl",cn);
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        dt = new DataTable();
        da.Fill(dt);

        chkType.DataSource = dt;
        chkType.DataTextField = "Name";
        chkType.DataValueField = "Id";
        chkType.DataBind();
    }
}




How to bind DropdownList from database


Here I will explain how to bind DropdownList from database
and in previous I posted this articles
how to access asp.net website in LAN
how to create database from script file
paging in html table using javascript

If you want to bind DropdownList from database table then you write following code in your website.


First , Your .aspx page should be like this



<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title> How to bind DropdownList from database </title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        Select: <asp:DropDownList ID="ddlType" runat="server">
        </asp:DropDownList>
    </div>
    </form>
</body>
</html>

And your C# code behind like this



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;
using System.Data.SqlClient;
using System.Configuration;

public partial class _Default : System.Web.UI.Page
{
    SqlConnection cn;
    DataTable dt;
    protected void Page_Load(object sender, EventArgs e)
    {
        cn = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
        if (!IsPostBack)
        {
            BindDropdwnlist();
        }

    }
    public void BindDropdwnlist()
    {
        SqlCommand cmd = new SqlCommand("SELECT id,Name from tbl",cn);
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        dt = new DataTable();
        da.Fill(dt);

        ddlType.DataSource = dt;
        ddlType.DataTextField = "Name";
        ddlType.DataValueField = "Id";
        ddlType.DataBind();
    }
}

how to access asp.net website in LAN

how to access asp.net website in LAN

Introduction:

Here I will explain how to access asp.net website or application in LAN. If you want to access asp.net website in LAN then do following step and you can access asp.net website, project or application in LAN. to access asp.net project in another pc which is connected in LAN. Actually one user of my blog reader has asked me solution for this" access  project on any to the any PC using local IP address " application.

we can access the asp.net website or project in LAN 

So, Now I explaining how to create chat application in asp.net using c# with WebSocket.

Description: 

In previously post I explained to  
Three tier architecture in asp.net
Remove .aspx from url in asp.net
how to create chat application in asp.net using c#
Change the column name or datatype or size in sql server
upload or publish web-site
Calling web service without adding web reference

Solution

 

Step 1: Fitst open your local server and go to IIS

Step 2: Create application or website in IIS

Step 3: and go to Start=>Run=>cmd=> ipconfig   - enter this command for get IP address ,
            take IPV4 address.

Step 4: Access the web site from another pc which is connected in LAN,
            you can use like this

    http://server-IPV4-Address/MyProjetName/MyPageName.aspx        OR
    http://server-Name/MyProjetName/MyPageName.aspx

Example:    

 

    http://105.105.105.105/problemaspdotnet/Home.aspx  
    http://MyServer/problemaspdotnet/Home.aspx    

Note:

  You can not use above in outside the LAN , only access in your LAN.



Tuesday 7 April 2015

how to create database from script file

--> some time required when new user register on particular website that time
     create new database automatically  from script file.

--> script file:  script file is database creation  code you can create script file from your exist database using asp.net with c# code

    how to create script file , the step is following
    -->right click on your database (SQL server 2008 )
    -->select script database as
    -->select create and file to
    -->and open save as dialogue box set name and path where you want save this script file
    -->and click save
    -->then some process is done and  create script file in your download folder or where you set the path when open dialogue box

-->and you must be changes path in script file (open script file and remove or change the local computer path) other-wise your code  gives error

--> add following code in your code behind file

    -->required following namespace
------------------------------------------------------------------------------------------------
    using Microsoft.SqlServer.Management.Smo;
    using Microsoft.SqlServer.Management.Common;

    -->and create following function
------------------------------------------------------------------------------------------------
    public void CreateDatabaseFromScriptfile()
    {
     cn4 = new SqlConnection(@"Data Source=path\SQLEXPRESS,53286;Initial Catalog=databasename;User ID=sa;Password=pwd;");    //Connecrtion string
           string strdbname = "db_" + txtAccountName.Text; //this is for new databsase name
           FileInfo file = new FileInfo(Server.MapPath("Database_Code") + "\\" + "scriptFile.sql");
           //Here  path where your script file is store
           string strscript = file.OpenText().ReadToEnd();
           // in strscript string variable assign script code for replace the database name and execute server side
           string strupdatescript = strscript.Replace("[OldDatabaseName]", strdbname);
           // OldDatabaseName which is you set : when you create script file from which database , set this database name
           Server server = new Server(new ServerConnection(cn4));
           server.ConnectionContext.ExecuteNonQuery(strupdatescript);
          //this executed on server side and create new database , and this database name is value of strdbname

    }

--> above function take some more time for create new database on server side

--> and this function use on click event or any where which you want to

Saturday 24 January 2015

the log for database is not available sql 2008

the log for database is not available sql 2008

The log for database 'x' is not available. Check the event log for related error messages. Resolve any errors and restart the database.

In this case your SELECT query fire but INSERT- UPDATE or DELETE command not fire on your database and gives this type of error

SOLUATIN:
1.First detach your database
2.and then attach your database
3.Refresh database

Now Your problem is Solved  .


Asp.net tutorials