|
<br />
Integrator:<br />
<Select name=Integrator id=Integrator Size=1 onChange=<br />
<%<br />
dim sqlTemp<br />
dim arrRSTemp<br />
dim ConnTemp : Set ConnTemp = cf_OpenConnection()<br />
<br />
sqlTemp = "Select * from Integrator where atnINtegratorID = 1"<br />
set arrRSTemp = Conn.Execute(sqlTemp)<br />
<br />
Response.Write "Integrator Address: " & arrRSTemp("txtIntegratorAddress")<br />
Response.Write "<br>"<br />
<br />
%>><br />
<br />
<option value=''>**No Integrator**</option><br />
<%<br />
do until arrRS_Integrator.EOF<br />
Response.Write "<option value='" & arrRS_Integrator.Fields(0).value & "'"<br />
Response.Write ">" & arrRS_Integrator.Fields(1).value & "</option>" & vbcrlf Call arrRS_Integrator.moveNext()<br />
loop<br />
%><br />
</select><br />
</code><br />
<br />
<br />
<br />
I have a combo which is used to dropdown some info. Now i want do some coding in the onchange event, as shown above. is this possible? please help me in this, because the code above is not working a bit.<br />
<br />
NB: I'm a beginner
|
|
|
|
|
AFAIK, this is not the correct way of doing it.
You must know that onChange function of the Select box will be executed on the client side. You have written code that will be executed on the server, which is wrong. So what you could do is:
onChange of combo box, write a javascript function which will post back the page to itself. Pass the selected id in the QueryString. Now check for the corresponding QueryString in the page.
If value is not null, write the code to get values from database (which you have already written).
The important thing here is you need to understand how Classic ASP works. Once you know that, it would be easy for you to write code using Classic ASP.
Xandip wrote: NB: I'm a beginner
I would suggest you to go for ASP.NET if you are starting with Classic ASP. It has a lot of advantages over Classic ASP. You can always Google for them.
..Go Green..
|
|
|
|
|
Hello,
I am working on a little tool to help multiple people write articles and I have hit a snag. Each article needs to have a unique, sequential id. This alone is not that difficult but I am wondering what the best way to implement it is as it seems like a waste to create a whole database just for tracking a "next id" field.
I was thinking of using a flat file (text/xml?) that the asp.net page reads from and then writes the new number right away. However, in that case how do I control concurrency (i.e. what if one person is reading in the split second before another writes their number back)? Or is this really an issue in something this simple?
Any advise on an appropriate method for keeping a "next id" information would be greatly appreciated.
|
|
|
|
|
If you can use a string, try System.Guid.NewGuid().ToString(). It's always unique.
Read this[(MSDN)]
|
|
|
|
|
But is that sequential? the OP mentioned sequential numbers.
|
|
|
|
|
Sorry. Sequential - i did not recognize it. It's late at night
|
|
|
|
|
Don't overlook the power of an Access database. (.mdb)
In access you have a field type which is "Autonumber"
In your website you might want to collect the following:
Date Time that number was requested
User who requested the number
Working title of the article
Your key to this table could be the Autonumber field.
Very easy to hook something like this up. Should be about 1 day of effort.
Access is perfect for this type of application.
|
|
|
|
|
why can't you slap some simple static class to do the job for you.
public static class SequentialNumbers
{
private static Object obj = new Object();
private static UInt16 lastNumber = UInt16.MinValue;
public static UInt16 GetNext()
{
lock (obj)
{
return ++lastNumber;
}
}
}
|
|
|
|
|
While there were several good answers, I have decided to go with this one with the slight change that I will write the number to disk each time it's generated. I know that will limit performance to an extent due to IO but I think it is important for to maintain the Durability of the process (i.e. if it crashes at some point, someone doesn't have to scour through every article to find out what the last valid number was).
A follow up question might be how to gently handle situations where people are waiting on the lock but I will try to find more information on this myself first before asking.
|
|
|
|
|
What does your tool do if that is the only thing it would use a database for? You don't track which authors contributed to an article? You don't have the titles stored separately for convenient listing? DateTime.Now.Ticks would give you a reasonably unique ordered but non-sequential ID.
|
|
|
|
|
Yeah, I realize it sounds a bit odd. Basically, it's a kludge to make it easier to write articles that are stored in another product that is too unwieldy to use. So yes all that information does get stored but in a DB that I have no access to. Thus my app only cares about the act of creating the article and not what happens to it afterward....
|
|
|
|
|
Can you use that other system to generate the ID by creating an article stub?
|
|
|
|
|
Well if all you need is a simple way to do this you might try loading the last id from a flat text file or xml in Application_Start throw that into the application state and then in Application_End save it to the database. This way you dont have to worry about concurrency issues because the id is stored in memory and is only written back to the file when the application ends.
void Application_Start(object sender, EventArgs e)
{
int id;
int.TryParse(System.IO.File.ReadAllText(Server.MapPath("~/nextid.txt")), out id);
Application["ID"] = id;
}
void Application_End(object sender, EventArgs e)
{
System.IO.File.Delete(Server.MapPath("~/nextid.txt"));
System.IO.File.WriteAllLines(Server.MapPath("~/nextid.txt"), new string[] { Application["ID"].ToString() });
}
public int GetNextID()
{
Application["ID"] = Convert.ToInt32(Application["ID"]) + 1;
return (int)Application["ID"];
}
Ofcourse you are going to want to add stuff like checking for the file before reading it and some error handling but im sure you get the point.
If at first you don't succeed ... post it on The Code Project and Pray.
|
|
|
|
|
Hi
I want to make a tips&tricks page;
I want to create something like codeproject Forums page.
What is your idea about the Component used to make this page in codeproject?
I mean the component that our questions and answers is exist and we can see our answers.(we click on the question and we can read our answer)
|
|
|
|
|
|
Hi i am trying to use data relation in my program.I have two repeaters used one nested another.
part of code is shown below:
void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
RepeaterItem item = e.Item;
if ((item.ItemType == ListItemType.Item) ||
(item.ItemType == ListItemType.AlternatingItem))
{
Repeater2 = (Repeater)e.Item.FindControl("Repeater2");
DataRowView drv = (DataRowView)item.DataItem;
Repeater2.DataSource = drv.CreateChildView("categoryItem");
Repeater2.DataBind();
}
}
the error is :
<pre>
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: The relation is not parented to the table to which this DataView points.
Source Error:
Line 121: Repeater2 = (Repeater)e.Item.FindControl("Repeater2");
Line 122: DataRowView drv = (DataRowView)item.DataItem;
Line 123: Repeater2.DataSource = drv.CreateChildView("categoryItem");
Line 124: Repeater2.DataBind();
This categoryItem is from this code:
objDA.Fill(ds);
Repeater1.DataSource = ds;
Repeater1.DataBind();
DataColumn c1 = ds.Tables["category"].Columns["ID"];
DataColumn c2 = ds.Tables["Item"].Columns["ProposalID"];
dRel = new DataRelation("categoryItem", c1, c2);
ds.Relations.Add(dRel);
Can anyone please figure it out why that error is there ?
suchita
modified on Tuesday, July 27, 2010 9:20 AM
|
|
|
|
|
well i thought its because the repeater1.bind() is before the datarelations. So I even put that after data relations as shown :
objDA.Fill(ds);
DataColumn c1 = ds.Tables["category"].Columns["categoryID"];
DataColumn c2 = ds.Tables["Item"].Columns["catID"];
dRel = new DataRelation("categoryItem", c1, c2);
ds.Relations.Add(dRel);
Repeater1.DataSource = ds;
Repeater1.DataBind();
Now the error is :
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 1222: objDA.Fill(ds);
Line 1223:
Line 1224: DataColumn c1 = ds.Tables["category"].Columns["categoryID"];
Line 1225: DataColumn c2 = ds.Tables["Item"].Columns["catID"];
Line 1226: dRel = new DataRelation("categoryItem", c1, c2);
suchita
|
|
|
|
|
You have already asked this, eventually, before. The answer is you need to learn to read the documentation and stop throwing things together hoping it will work.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
i changed it little bit. I tried to use dataRelation before repeater get binded. that resolves the previous error but it gave different error says
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 1222: objDA.Fill(ds);
Line 1223:
Line 1224: DataColumn c1 = ds.Tables["category"].Columns["ID"];
Line 1225: DataColumn c2 = ds.Tables["item"].Columns["catID"];
Line 1226: dRel = new DataRelation("categoryItem", c1, c2);
my code is:
void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
RepeaterItem item = e.Item;
if ((item.ItemType == ListItemType.Item) ||
(item.ItemType == ListItemType.AlternatingItem))
{
Repeater2 = (Repeater)e.Item.FindControl("Repeater2");
DataRowView drv = (DataRowView)item.DataItem;
Repeater2.DataSource = drv.CreateChildView("categoryItem");
Repeater2.DataBind();
}
}
the changed code is in this block:
objDA.Fill(ds);
DataColumn c1 = ds.Tables["category"].Columns["ID"];
DataColumn c2 = ds.Tables["Item"].Columns["catID"];
dRel = new DataRelation("categoryItem", c1, c2);
ds.Relations.Add(dRel);
Repeater1.DataSource = ds;
Repeater1.DataBind();
the "ID" of table "category" is the foreign key in "item" table and that foreignKey name in the "item" table is "catID". But the error is something wrong with those IDs.
suchita
|
|
|
|
|
how to find whether div style is already visible or hidden using jquery in aspx page.
i have now like
<pre>if( $('#obj').css('display') == "none" )
{
alert('hi');
}
else
{
alert('hi%');
}</pre>
|
|
|
|
|
if( $('#obj').is(":visible") == true )
{
alert('div is visible');
}
else
{
alert('div is hidden');
}
|
|
|
|
|
Thanks for your reply ,
my hidden is open but it still shows invisible.
pls advice me
function expandcollapse(obj,row)
{
debugger;
alert(obj+'expandcollapse');
var div = $('#obj');
var img = 'img' +obj;
alert($('div').css('display'))
}
|
|
|
|
|
|
Hi all
I need to get backup of my database(sql 2005 & above) in script format not in.bak format.How can I do this?
I need all like tables,& table records,Store procedure etc in script format this is important.
Any help would be appreciated......
Amit
|
|
|
|
|
Hi friends
I have defalut.aspx page in My web Application. I want to load dynamic content into this page.
for example if i have url "http://www.cricinfo.com" which contains html content right. so i want to load this content into my default.aspx page.
Please help me how to do it?
|
|
|
|