|
Hi Paul,
Thank you for the immediate reply.I am sending code put it in pre tags...
CODEBEHIEND CODE:
Using System;
Using System.Data;
Using System.Data. SqlClient;
Using System.Configuratio n;
Using System.Web.Configur ation;
Using System.Collections;
Using System.Web;
Using System.Web.Security ;
Using System.Web.UI;
Using System.Web.UI. WebControls;
Using System.Web.UI. WebControls. WebParts;
Using System.Web.UI. HtmlControls;
Using System.Text;
Public partial class ClientCallBack : System.Web.UI.Page, System.Web.UI.ICallbackEventHandler
{
private string raiseCallArgument, stateId;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string strConnection = WebConfigurationMan ager.ConnectionStrings["DemoConn"].ConnectionString;
SqlConnection con = new SqlConnection(strConnection) ;
string strSQL = "SELECT DISTINCT * FROM tblRmStateMaster";
using (con)
{
con.Open();
SqlCommand objCmd = new SqlCommand(strSQL, con);
SqlDataReader dtReader = objCmd.ExecuteReade r();
using (dtReader)
{
if (dtReader.HasRows)
{
ddl.DataSource = dtReader;
ddl.DataTextField = "Statename";
ddl.DataValueField = "Statename";
ddl.DataBind( );
}
}
}
}
if (Request.Browser. SupportsCallback )
{
string callbackRef = Page.ClientScript. GetCallbackEvent Reference(this, "document.forms[ 0].elements[ 'ddl'].value", "CallbackonClientsi de", "null");
ddl.Attributes["onChange"] = callbackRef;
}
}
public void RaiseCallbackEvent(string raiseCallArgument)
{
this.raiseCallArgument = raiseCallArgument;
stateId = this.raiseCallArgument;
}
public string GetCallbackResult( )
{
StringBuilder returnString = new StringBuilder();
using (SqlConnection cn = new SqlConnection(ConfigurationManage r.ConnectionStrings["DemoConn"].ToString() ))
{
cn.Close();
cn.Open();
SqlCommand cmd1 = new SqlCommand("select * from tblRmStateMaster where Statename='" + stateId + "' ", cn);
SqlDataReader dr;
dr = cmd1.ExecuteReader( );
string str = "";
while (dr.Read())
{
str = dr[
"Stateid"].ToString() ;
}
dr.Close();
cn.Close();
int a = ddl.SelectedIndex + 1;
string exp = raiseCallArgument;
try
{
cn.Open();
SqlCommand cmd = new SqlCommand("select DISTINCT * from tblRmCountyMaster where Stateid=" + str, cn);
SqlDataReader rdr1 = cmd.ExecuteReader( );
using (rdr1)
{
while (rdr1.Read() )
{
returnString. Append(rdr1[ 2]);
returnString. Append(",");
}
}
rdr1.Close() ;
cn.Close();
}
catch (Exception ex)
{
Response.Write( ex.Message) ;
}
}
return returnString. ToString( );
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Write( ddl.SelectedItem .Text);
Response.Write( DropDownList1. SelectedItem. Text);
}
}
ASPX CODE:
<%
@ Page Language="C#" AutoEventWireup="true" CodeFile="ClientCallBack. aspx.cs" Inherits="ClientCallBack" EnableEventValidati on="false" %>
<!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional/ /EN" "http://www. w3.org/TR/ xhtml1/DTD/ xhtml1-transitio nal.dtd">
<
html xmlns="http://www. w3.org/1999/ xhtml">
<
head id="Head1" runat="server">
<title>Client Callback on ChillapzLocal</title>
<script type="text/javascript" language="javascript">
function CallbackonClientsid e(stringResult, context)
{
var listCompany = document.forms[ 0].elements['DropDownList1'];
listCompany. innerHTML =
"";
var entries = stringResult. split(',');
var str = "";
for(var i=0;i<entries.length- 1;i++)
{
var company = entries[i];
var item = document.createElem ent('option');
item.value = company;
item.innerHTML = company;
listCompany. appendChild( item);
}
}
</script>
</
head>
<
body>
<form id="form1" runat="server">
<div>
State:
<asp:DropDownList ID="ddl" runat="server">
</asp:DropDownList>
<br />
<br />
County:
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList> <br />
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /></div>
</form>
</
body>
</
html>
|
|
|
|
|
Hi paul,
I posted aspx source code but in that code i had two dropdownlist and one button control those controls are not displaying in the posted message.why it is not appearing?
|
|
|
|
|
You may have to step through the code, cannot really tell where the problem is.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hi Paul,
Just go through the below link
http://www.remapper.com/callback.aspx
In that i have two dropdownlists,I will select state from first dropdownlist then those counties will be appear in second dropdownlist without postaback of the page.I am getting but if i click the button for retreiving selected state and county value then county values are disappeared.
|
|
|
|
|
hello dharini,
try to keep the countrydropdownlist in AutPostBack=True or otherwise how ur calling the values of the dropdownlist of country like that call that function int the button click event.
ok then u will get
byeee
Murali
Murali
|
|
|
|
|
Hi Murali,
Thank you for the reply.Actually,my requirement is fill the county dropdownlist with out page postback.I am sending my code below...Just go thru it....That code copy into ur application and check it.
CODEBEHIEND CODE:
Using System;
Using System.Data;
Using System.Data. SqlClient;
Using System.Configuratio n;
Using System.Web.Configur ation;
Using System.Collections;
Using System.Web;
Using System.Web.Security ;
Using System.Web.UI;
Using System.Web.UI. WebControls;
Using System.Web.UI. WebControls. WebParts;
Using System.Web.UI. HtmlControls;
Using System.Text;
Public partial class ClientCallBack : System.Web.UI.Page, System.Web.UI.ICallbackEventHandler
{
private string raiseCallArgument, stateId;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string strConnection = WebConfigurationMan ager.ConnectionStrings["DemoConn"].ConnectionString;
SqlConnection con = new SqlConnection(strConnection) ;
string strSQL = "SELECT DISTINCT * FROM tblRmStateMaster";
using (con)
{
con.Open();
SqlCommand objCmd = new SqlCommand(strSQL, con);
SqlDataReader dtReader = objCmd.ExecuteReade r();
using (dtReader)
{
if (dtReader.HasRows)
{
ddl.DataSource = dtReader;
ddl.DataTextField = "Statename";
ddl.DataValueField = "Statename";
ddl.DataBind( );
}
}
}
}
if (Request.Browser. SupportsCallback )
{
string callbackRef = Page.ClientScript. GetCallbackEvent Reference(this, "document.forms[ 0].elements[ 'ddl'].value", "CallbackonClientsi de", "null");
ddl.Attributes["onChange"] = callbackRef;
}
}
public void RaiseCallbackEvent(string raiseCallArgument)
{
this.raiseCallArgument = raiseCallArgument;
stateId = this.raiseCallArgument;
}
public string GetCallbackResult( )
{
StringBuilder returnString = new StringBuilder();
using (SqlConnection cn = new SqlConnection(ConfigurationManage r.ConnectionStrings["DemoConn"].ToString() ))
{
cn.Close();
cn.Open();
SqlCommand cmd1 = new SqlCommand("select * from tblRmStateMaster where Statename='" + stateId + "' ", cn);
SqlDataReader dr;
dr = cmd1.ExecuteReader( );
string str = "";
while (dr.Read())
{
str = dr[
"Stateid"].ToString() ;
}
dr.Close();
cn.Close();
int a = ddl.SelectedIndex + 1;
string exp = raiseCallArgument;
try
{
cn.Open();
SqlCommand cmd = new SqlCommand("select DISTINCT * from tblRmCountyMaster where Stateid=" + str, cn);
SqlDataReader rdr1 = cmd.ExecuteReader( );
using (rdr1)
{
while (rdr1.Read() )
{
returnString. Append(rdr1[ 2]);
returnString. Append(",");
}
}
rdr1.Close() ;
cn.Close();
}
catch (Exception ex)
{
Response.Write( ex.Message) ;
}
}
return returnString. ToString( );
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Write( ddl.SelectedItem .Text);
Response.Write( DropDownList1. SelectedItem. Text);
}
}
ASPX CODE:
<%
@ Page Language="C#" AutoEventWireup="true" CodeFile="ClientCallBack. aspx.cs" Inherits="ClientCallBack" EnableEventValidati on="false" %>
<!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional/ /EN" "http://www. w3.org/TR/ xhtml1/DTD/ xhtml1-transitio nal.dtd">
<
html xmlns="http://www. w3.org/1999/ xhtml">
<
head id="Head1" runat="server">
<title>Client Callback on ChillapzLocal</title>
<script type="text/javascript" language="javascript">
function CallbackonClientsid e(stringResult, context)
{
var listCompany = document.forms[ 0].elements['DropDownList1'];
listCompany. innerHTML =
"";
var entries = stringResult. split(',');
var str = "";
for(var i=0;i<entries.length- 1;i++)
{
var company = entries[i];
var item = document.createElem ent('option');
item.value = company;
item.innerHTML = company;
listCompany. appendChild( item);
}
}
</script>
</
head>
<
body>
<form id="form1" runat="server">
<div>
State:
<asp:DropDownList ID="ddl" runat="server">
</asp:DropDownList>
<br />
<br />
County:
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList> <br />
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /></div>
</form>
</
body>
</
html>
|
|
|
|
|
dharanighanta wrote: my requirement is fill the county dropdownlist with out page postback
Why? I doubt it is possible without page postback. Anytime I've done web stuff that required populating a control after another control had some user action performed on it, I've always had to run the page through again but the next time, conditional branches guiding the behind the scenes code based on that user action.
I don't know much about Ajax, but maybe that could help.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Friends,
I am working on a Product which is migrated from Visual Basic 6.0 to .NET 2.0.
The product uses ADO Connection object. And the connection object is using Reshape Name Property (MSDataShape) and SHAPE method to concatenate set of tables.
Right now, the DB Connection is using Standard Login Method. We are trying to implement Integrated Security Login. This MSDataShape does not supporting Integrated Security. Any one has solution without removing MSDataShape to achieve Integrated Security?
Current ConnectionString,
"Provider=MSDataShape; Data Provider=MSDASQL; DSN=MyDSN; UID=user1; PWD=pass;"
I tried as,
"Provider=MSDataShape; Data Provider=MSDASQL; DSN=MyDSN; Integrated Security = SSPI"
|
|
|
|
|
This doesn't look like an ASP.NET question to me ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
The Product is development as an IIS Application (WebClass) in VB 6.0, which is migrated to ASP.NET application.
|
|
|
|
|
Have a wizard on a page, with a few fields and validators for some of them.
Also, have a login control (the standard one that comes in asp.net). Well, if I try logging in, the validators on the wizard fire up and basically I cannot login unless the fields in teh wizard are filled. Pretty funny, but any idea how to, sorta group the validators, so when I use the login control it does _not_ check the wizard's validators?
Thanks in advance.
|
|
|
|
|
Hello Everyone,
I want to run my uploaded videos in realplayer or quicktime or mediaplayer
in my program My videos can be flash files or anything else
Thnx & Regards
Manoj Bisht
|
|
|
|
|
Hi All,
I am working with ASP.NET2.0(VB) and want to merge two GridView on button click. Is there any way of doing this.
Please help...
Thanks in advance...
|
|
|
|
|
please explain ur question
B asharatA li
Internee
METESYS Lahore
Pakistan
|
|
|
|
|
Thanks for the reply, I need one Gridview with 5 rows and another gridview with 2 rows and I need to merge this two gridview show 7 rows.
Is there any way???
|
|
|
|
|
your both gried view have same columns and if u r binding ur gridview then try to merge both tables (Dim dt as Data.Table) in seprate table and bind it with gridview
B asharatA li
Internee
METESYS Lahore
Pakistan
|
|
|
|
|
try like this
Table1 (with 5 rows)<br />
Table2 (with 2 rows)<br />
<br />
<br />
Dim Dt As Data.DataTable<br />
Dim dr As Data.DataRow<br />
<br />
<br />
dt = Table1<br />
<br />
For index As Integer = 1 To LeaveReacordTable1.Rows.Count - 1<br />
dr = dt.NewRow<br />
dr.Item("Column Name 1") = LeaveReacordTable1.Rows(index)("Column Name 1")<br />
dr.Item.....<br />
dt.Rows.Add(dr)<br />
<br />
Next<br />
GridView1.DataSource = dt<br />
GridView1.DataBind()
Is it helpfull?
B asharatA li
Internee
METESYS Lahore
Pakistan
|
|
|
|
|
I tried doing that before only but its giving me repeated records.... In check ur code but didnt get what is LeaveReacordTable1??
Actually problem is that I have 3 gridview on my form original, search and Import from excel Gridview. When the page is load Original gridview is displayed if I do any searching then search girdview is displayed and other two r visible false. Finally if I import data from excel then I need to merge that gridvie with any of the one which is visible with no data repeating. This proceed can be done is random way also. I mean I can first import and then search or vice versa..
Please help me...
|
|
|
|
|
sorry it's (LeaveReacordTable1) Table2
B asharatA li
Internee
METESYS Lahore
Pakistan
|
|
|
|
|
I tried doing that before only but its giving me repeated records.... In check ur code but didnt get what is LeaveReacordTable1??
Actually problem is that I have 3 gridview on my form original, search and Import from excel Gridview. When the page is load Original gridview is displayed if I do any searching then search girdview is displayed and other two r visible false. Finally if I import data from excel then I need to merge that gridvie with any of the one which is visible with no data repeating. This proceed can be done is random way also. I mean I can first import and then search or vice versa..
Please help me...
|
|
|
|
|
u r getting records in some table before displaying them in gridview
if u have same structure of your tables Search, Import....
then
let suppose if u have records in SearchDataTable wich u r binding with GridViewSearch and now u want to display ur ImportDataTable records in same SearchGridVeiw then u have todo somthing like this
SearchDataTable (with 5 rows)
ImportDataTable (with 2 rows)
'Creat a new DataTable and DataRow
Dim Dt As Data.DataTable
Dim dr As Data.DataRow
dt = SearchDataTable
For index As Integer = 1 To ImportDataTable.Rows.Count - 1
dr = dt.NewRow
dr.Item("Column Name 1") = ImportDataTable.Rows(index)("Column Name 1")
dr.Item("Column Name 2") = ImportDataTable.Rows(index)("Column Name 2")
dr.Item.....
dt.Rows.Add(dr)
Next
SearchGridVeiw.DataSourceID=""
SearchGridVeiw.DataSource = dt
SearchGridVeiw.DataBind()
B asharatA li
Internee
METESYS Lahore
Pakistan
|
|
|
|
|
|
function Cover(botto,top,ignoreSize){
var location=Sys.UI.DomElement.getLocation(bottom);
top.style.position='absolute';
top.style.top=location.y+'px';
if(!ignoreSize){
top.style.height=bottom.offsetHeight+'px';
top.style.width=bottom.offsetWidth+'px';
}
}
does anyone know how to convert this java code to visual basic
or a software to perform the convertion
|
|
|
|
|
Apart from the Sys.UI.DomElement, this looks like javascript to me. No tool will convert java to VB, or javascript to VB. The core thing is, what does this code do ? It looks like client side code to me, and VB runs on the server, so a conversion won't help you.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
whts the difference between java and javascript
anyways i hate java coding
thx for replying though
|
|
|
|