|
Hi guys
I am listing more than 100 items in a dropdownlist.
How to select the items just by typing first few letters through keyboard, so that the items starting with that letters is selected?
For example, am having "a,ab,abc,abcde,abcdef,abcdefg..." in the list.
When i type/press 'a' then 'b' and then 'c',now the item 'abc' should be the selecteditem in the order of display.
Can anyone please help me?
Thanks
|
|
|
|
|
|
Thanks
But i have to code in VS.NET 2003 with ASP.NET 1.1 only.
Please tell me!
|
|
|
|
|
|
Hi all,
I want to add the selected element from one listbox to another listbox and remove also on button click event >(button text for add) and <(button text for remove).
Also I need to add all the element from one listbox to another and remove also on button click event >>(button text for add all) and <<(button text for remove all).
I want to do this with Javascript.
Please help me as I have to do this by today.
Thanks in advance.
|
|
|
|
|
Hey Varsha,
Use this code. This code has a ability to move the Selected Items from source to target. You can alter it as you like.
function AddItem(src,target){
for (i=src.length-1; i>=0; i--){
if (src[i].selected){
for (j=0; j < target.options.length; j++){
if (src.options[i].text.toUpperCase() < target.options[j].text.toUpperCase())
break;
}
var oOptions = document.createElement("option");
target.options.add(oOptions,j);
oOptions.value=src.options[i].value;
oOptions.innerHTML=src.options[i].innerHTML;
src.options.remove(i);
}
}
}
|
|
|
|
|
Thanks for the reply sir. I got some code but its not working I am not able to track whats wrong.
<html>
<head>
<script language="JavaScript">
function f_optionMove(s_from, s_to)
{
alert(s_from);
var e_from = document.forms['test_form'].elements[s_from],e_to = document.forms['test_form'].elements[s_to];
alert(e_from);
if (!e_from)
return alert ("Error: selectbox with name '" + s_from + "' can't be found.");
if (!e_to)
return alert ("Error: selectbox with name '" + s_from + "' can't be found.");
var n_moved = 0;
for (var i = 0; i < e_from.options.length; i++)
{
if (e_from.options.selected)
{
e_to.options[e_to.options.length] = new Option(e_from.options.text, e_from.options.value);
n_moved++;
}
else if (n_moved)
e_from.options[i - n_moved] = new Option(e_from.options.text, e_from.options.value);
}
if (n_moved)
e_from.options.length = e_from.options.length - n_moved;
else
alert("You haven't selected any options");
}
function f_optionMoveAll(s_from, s_to)
{
var e_from = document.forms['test_form'].elements[s_from],e_to = document.forms['test_form'].elements[s_to];
if (!e_from)
return alert ("Error: selectbox with name '" + s_from + "' can't be found.");
if (!e_to)
return alert ("Error: selectbox with name '" + s_from + "' can't be found.");
e_to.options.length = 0;
for (var i = 0; i < e_from.options.length; i++)
e_to.options = new Option(e_from.options.text, e_from.options.value);
e_from.options.length = 0;
}
function f_selectAll (s_select)
{
var e_select = document.forms['test_form'].elements[s_select];
for (var i = 0; i < e_select.options.length; i++)
e_select.options.selected = true;
}
</script>
</head>
<body>
<form id="test_form" name="test_form" runat="server">
<table border="0" cellpadding="0" cellspacing="0" style="width: 100%">
<tr>
<td>
<select multiple name="source" style="width: 170px; height: 170px">
<option>Vishal</option>
<option>Pooja</option>
<option>Dnyandeo</option>
<option>Varsha</option>
<option>Aditi</option>
<option>Nilesh</option>
</select>
</td>
<td>
<table border="0" cellpadding="0" cellspacing="0" style="width: 100%">
<tr>
<td>
<input type="Button" style="width: 200px;" value="Add Selected >>" onclick="f_optionMove('source', 'destination')">
</td>
</tr>
<tr>
<td>
<input type="Button" style="width: 200px;" value="Remove Selected <<" onclick="f_optionMove('destination', 'source')">
</td>
</tr>
<tr>
<td>
<input type="Button" style="width: 200px;" value="Add All >>" onclick="f_optionMoveAll('source', 'destination')">
</td>
</tr>
<tr>
<td>
<input type="Button" style="width: 200px;" value="Remove All <<" onclick="f_optionMoveAll('destination', 'source')">
</td>
</tr>
<tr>
<td>
<input type="Button" style="width: 200px;" value="Select All Sources" onclick="f_selectAll('source')"></td>
</tr>
<tr>
<td>
<input type="Button" style="width: 200px;" value="Select All Destinations;" onclick="f_selectAll('destination')"></td>
</tr>
</table>
</td>
<td>
<select multiple name="destination" style="width: 170px; height: 170px">
</select>
</td>
</tr>
</table>
</form>
</body>
</html>
Please tell me where I am going wrong.
|
|
|
|
|
The corrected script is,
<script language="JavaScript">
function f_optionMove(s_from, s_to)
{
var e_from = document.forms['test_form'].elements[s_from],e_to = document.forms['test_form'].elements[s_to];
if (!e_from)
return alert ("Error: selectbox with name '" + s_from + "' can't be found.");
if (!e_to)
return alert ("Error: selectbox with name '" + s_from + "' can't be found.");
var n_moved = 0;
for (var i = 0; i < e_from.options.length; i++)
{
if (e_from.options[i].selected)
{
e_to.options[e_to.options.length] = new Option(e_from.options[i].text, e_from.options[i].value);
n_moved++;
}
else if (n_moved)
e_from.options[i - n_moved] = new Option(e_from.options[i].text, e_from.options[i].value);
}
if (n_moved)
e_from.options.length = e_from.options.length - n_moved;
else
alert("You haven't selected any options");
}
function f_optionMoveAll(s_from, s_to)
{
var e_from = document.forms['test_form'].elements[s_from],e_to = document.forms['test_form'].elements[s_to];
if (!e_from)
return alert ("Error: selectbox with name '" + s_from + "' can't be found.");
if (!e_to)
return alert ("Error: selectbox with name '" + s_from + "' can't be found.");
e_to.options.length = 0;
for (var i = 0; i < e_from.options.length; i++)
e_to.options[e_to.options.length] = new Option(e_from.options[i].text, e_from.options[i].value);
e_from.options.length = 0;
}
function f_selectAll (s_select)
{
var e_select = document.forms['test_form'].elements[s_select];
for (var i = 0; i < e_select.options.length; i++)
e_select.options[i].selected = true;
}
</script>
|
|
|
|
|
hello ,
I am providing a feature of hit highlight in my application developed on .net 2005 using vb.net.
I would like to know how can i search and highlight text in PDF files, what all the dll's to be added in the refference to get the object. what are the different types of PDF files and on wich type of file can this highlight be applicable. Waiting for ur kind help
amrita
|
|
|
|
|
Following is the code that i have written to write contents of response object into an ExcelSheet.
<br />
Response.Clear();<br />
Response.Buffer = true;<br />
Response.ContentType = "application/vnd.ms-excel";<br />
Response.Charset = "";<br />
string sep = "";<br />
foreach (DataColumn dc in dt.Columns)<br />
{<br />
Response.Write(sep + dc.ColumnName);<br />
sep = "\t";<br />
}<br />
Response.Write("\n");<br />
<br />
int count;<br />
foreach (DataRow drow in dt.Rows)<br />
{<br />
sep = "";<br />
for (count = 0; count < dt.Columns.Count; count++)<br />
{<br />
Response.Write(sep + drow[count].ToString());<br />
sep = "\t";<br />
}<br />
Response.Write("\n");<br />
}<br />
If less than 30 records are there in the response , its not writting in the excel sheet.
Plzzzz help me
Mads
|
|
|
|
|
hi friends
i have two forms
1.login form
2.timesheet form
log inform database contains employeeid,username,password columns.
statically i give someusername,password in database table.
now username,password is correct it will redirect to timesheet form
my query is
how can i get the employee id using usernamefrom loginform to timesheetform
i want to store employee id in session
thanks in advance
regards
saravanan
|
|
|
|
|
What you are asking here is really basic, you simply take the input value from the login form then execute a simple query against DB to select the value. There are tons of tutorials out there that you can learn, you might also download the starter kits from the Microsoft ASP.NET site to learn from them.
|
|
|
|
|
You get it like this:
LoginControl1.UserName.Trim();
|
|
|
|
|
I followed the article here http://www.kirupa.com/net/sql_asp_introduction.htm
everything compiles ok but when it get to opening the database I get error message
An attempt to attach an auto-named database for file C:\Path\Games.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share
I do not have any other databases with the same name and it is on the C drive so leads me to believe for some reason it can not open the database.
could someone please help me with this.
Thanks
|
|
|
|
|
|
ok i figured out what was wrong, .net 2.0 needed to be reinstalled, my app now runs but does not write to the database, is there something wrong with my code to write to the database?
SqlConnection connection;
protected void Page_Load(object sender, EventArgs e)
{
connection = new SqlConnection(ConfigurationManager.ConnectionStrings["GameConnection"].ConnectionString);
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
SqlCommand command = new SqlCommand("INSERT INTO gameTable(gameName, gamePlatform) VALUES (@id_gameName,@id_gmaePlatform)", connection);
SqlParameter nameContent = new SqlParameter("@id_gameName", SqlDbType.VarChar);
nameContent.Value = txtName.Text;
command.Parameters.Add(nameContent);
SqlParameter platformContent = new SqlParameter("@id_gamePlatform", SqlDbType.VarChar);
platformContent.Value = txtPlatform.Text;
command.Parameters.Add(platformContent);
connection.Open();
command.BeginExecuteNonQuery();
connection.Close();
Response.Redirect("Results.aspx");
}
|
|
|
|
|
Planker wrote: command.BeginExecuteNonQuery();
connection.Close();
You make an asynchronous call to insert data, but you close the connection right after that then how data can be inserted into DB. You might also double check the parameter name gmaePlatform as well.
|
|
|
|
|
I have a GridView that displays rows of pictures along with text that describes the pictures. When I click on the picture I would like another page to display. How do I write an event for that, or can I configure the Imagefield in the GridView to do this? Thanks.
|
|
|
|
|
AFAIK, the ImageField does not allow you to define the event handler in the field markup, instead you'll need to use the RowCreated/RowDataBound event of the GridView control and try to get reference to the Image control, then register your event handler script. Another option is to use the Image control with the TemplateField in lieu of the ImageField and you can easily add the event handler for the Image control in the template.
|
|
|
|
|
You shouldn't need any event handlers, a template field with an image link will do the trick.
|
|
|
|
|
hi friends
i want display the current date in textbox.how can i bind the date with c#,asp.net
plz give me the code
regards
saravanan
|
|
|
|
|
SomeTextBoxThatYouHave.Text = DateTime.Now.ToString("d", TheFormatInfoOrCultureInfoThatYouWantToUse);
---
Year happy = new Year(2007);
|
|
|
|
|
hi
thanks for reply
i want currentdate only.i dont want time.date is dd/MM/yyyy this format
regards
saravanan
|
|
|
|
|
You can't get only a date. The DateTime structure is used to handle dates and times, and there is no Date structure wihtout time. The time is always there, even if it's 0:00, it's still there. It's no problem, though, as you choose what you want to display when you convert the DateTime value to a string.
The formatting string that you use in the call to ToString determines the format. The "d" string specifies the use of a short date format. The short date format is depending on the culture, so you should specify a FormatInfo or CultureInfo object to determine the culture to be used.
---
Year happy = new Year(2007);
|
|
|
|
|
Try like this,
sometextbox.Text = Now.ToString("dd/MM/yyyy")
|
|
|
|