Coding to populate state and city Acording to country Without Post back In Asp.net

Here I Show how to Fill Country,State and city.State Depend On Country So
if Country changed then State Dynamically Changed Without Postback.Similar City Depend on state So if We Change State then need to city also changed this can be done in asp.net without postback with
following methods :
In Asp.net We Need to Register Script so later we can call this Function
Write down Following code in .Cs
protected void country_fill()
{
DataSet Search_dataset = new DataSet();
SqlDataAdapter sda = new SqlDataAdapter("(select state_code,state_name,country_code from state_master) (select city_code,city_name,state_code from city_master)", con);
sda.Fill(Search_dataset);
string str = "";
str = " < script language=" + '"' + "javascript" + '"' + " > \n";
str += "var state = Array(" + (Search_dataset.Tables[0].Rows.Count + 1) + ");\n";
str += "var city = Array(" + (Search_dataset.Tables[1].Rows.Count + 1) + ");\n";
str += "function createarray(){\n";
str += "var i;\n";
str += "//create item array \n";
str += "for(i=0;i<>
str += "var a = new Array(3);\n";
str += "state[i] = a; }\n";
int i = 0;
foreach (DataRow Objdrow in Search_dataset.Tables[0].Rows)
{
str += "state[" + i + "][0]='" + Objdrow["state_code"] + "';\n";
str += "state[" + i + "][1]='" + Objdrow["state_name"] + "';\n";
str += "state[" + i + "][2]='" + Objdrow["country_code"] + "';\n";
i += 1;
}
str += "var j;\n";
str += "//create item array \n";
str += "for(j=0;j<>
str += "var b = new Array(3);\n";
str += "city[j] = b; }\n";
i = 0;
foreach (DataRow Objdrow1 in Search_dataset.Tables[1].Rows)
{
str += "city[" + i + "][0]='" + Objdrow1["city_code"] + "';\n";
str += "city[" + i + "][1]='" + Objdrow1["city_name"] + "';\n";
str += "city[" + i + "][2]='" + Objdrow1["state_code"] + "';\n";
i += 1;
}
str += "}\n"; //end of function
str += " < /script > \n";
//Page.RegisterClientScriptBlock("fill_item", str);
Page.RegisterClientScriptBlock("fill_item", str);
}
Now in ASpx Page On combo Box Changed Write Down following Code.
function fill_spec() //handle keyup on model_name
{
var selectcmb_func,spec_array_length,selectfunc_id,selectcmb_spec,selecttxt_spec_id;
spec_array_length = state.length;
selectcmb_func = document.forms.DropDownList1;
selectcmb_func=document.getElementById("");
selectcmb_spec = document.getElementById("");
selectfunc_id = selectcmb_func.options[selectcmb_func.selectedIndex].value;
numShown=0;
selectcmb_spec.length=0;
selectcmb_spec[numShown] = new Option("-- Select State -- ","0");
numShown++;
for(i = 0; i <>
{
if( (state[i][2]==selectfunc_id) || (state[i][2]==0))
{
selectcmb_spec[numShown] = new Option(state[i][1],state[i][0]);
numShown++;
}
}
}
function fill_city() //handle keyup on model_name
{
var city_length,ddl_state,ddl_city,id,numShown;
city_length = city.length;
ddl_state=document.getElementById("");
ddl_city = document.getElementById("");
id = ddl_state.options[ddl_state.selectedIndex].value;
numShown=0;
ddl_city.length=0;
ddl_city[numShown] = new Option("-- Select City -- ","0");
numShown++;
for(i = 0; i <>
{
if( (city[i][2]==id) || (city[i][2]==0))
{
ddl_city[numShown] = new Option(city[i][1],city[i][0]);
numShown++;
}
}
}
hear you need to call function createarray .You can call this function in page load.


Prev Post                                                      All Post                                                           Next Post


Posted in | 0 comments

Share Good Documents

.NET Framework Security
Building Secure ASP.NET Applications: Authentication, Authorization, and Secure Communication
http://msdn.microsoft.com/en-us/library/aa302415.aspx




Prev Post                                 All Post                                                Next Post




Posted in | 3 comments

Convert Image to ByteArray And ByteArray to Image in Asp.Net

Convert Image to ByteArray And ByteArray to Image in Asp.Net


Convert Image to ByteArray
Following code Convert PictureBox image (You can take manually image from any folder) to ByteArray
MemoryStream ms = new MemoryStream();
this.pictureBox2.Image.Save(ms, ImageFormat.Jpeg);
// now save the stream as a byte array
Byte[] imageBytes = new Byte[ms.Length];
ms.Seek(0, SeekOrigin.Begin); // must rewind from the write
ms.Read(imageBytes, 0, (int)ms.Length);
ms.Close();
Now imageBytes Contains Image as a ByteArray.
Convert ByteArray to Image
Now Convert Above Bytearray in to Image.
System.IO.FileStream ms = new System.IO.FileStream(path_name + id_badge + ".jpg", System.IO.FileMode.Create, System.IO.FileAccess.Write);
//Where you Want to Save Image
//You Can Also Save In Control
ms.Write(imageBytes, 0, imageBytes.Length);
ms.Close();


Prev Post                                                      All Post                                                           Next Post


Posted in | 3 comments

Open Child Window From Parent Window using Java script , Refresh Parent When Child Window Closed.

in parent Window

Response.Write(" < script > window.open('Vacancy_Detal.aspx?lbl_vac_code=" + vac_code.Text + "','','left=150px,top=70px,width=812,height=650,
scrollbars=yes,toolbar=0,
resizable=0,location=no,status=no'); < /script > "
);
In Child Window
Response.Write(" < script > window.opener.location.href='Vacancy_Detal.aspx '; < /script >");
Response.Write(" < script > self.close(); < /script >");


Prev Post                                                      All Post                                                           Next Post

Posted in | 1 comments

Book Mark In ASP.Net

Book Mark In ASP.Net


After Performing Some action in Asp.net application There are Required to jump on Specific
Control or Specific Part of Page.It's Can Be archive by Following method.

Write Down Following code in ASP.net .Aspx Source Code.

< a name="jumphere1" > < /a >

Write down following Code in .Cs File



     private void registerAnchorScript(String strAnchorID)
    {
        String Script = "";

        Script += " < script language=JavaScript id='BookMarkScript' > ";
        Script += "var hashValue='#" + strAnchorID + "';";
        Script += "if(location.hash!=hashValue)";
        Script += "location.hash=hashValue;";
        Script += " < /script > ";
        Response.Write(Script);
        if (Page.IsStartupScriptRegistered("BookMarkScript"))
        {
            Page.RegisterStartupScript("BookMarkScript", Script);
        }

    }
Write Down Following Code in Some Event's Like Page Load,Click or else from where you
want to jump on specific Part of page.


registerAnchorScript("jumphere1");



Prev Post                                                      All Post                                                           Next Post

Posted in | 0 comments

Submit your Idea.

If you have any logic or tricks on .net Then Please Post on Below comment Box I make it Proper Post and Format and if you Want to give email id for discussion then it's also Nice for Reader.please if possible then give your name or contact so in post i write it.
Thank you in advance.


Prev Post                                                      All Post                                                           Next Post



Posted in | 1 comments

ASK Your Question.

Lets Discuss your Difficulty Here.


Prev Post                                                      All Post                                                           Next Post 

Posted in | 7 comments