|
Hello ;
I added master page(MasterPage.master) ..and I add web page(default.aspx ) that use to that master page and I want
to use javaScript code in web page (default.aspx) ,to get the value of textbox1 in (default.aspx)...
how can I do that
I have tried
<asp:Content ...>
<script type="text/javascript" >
function ere()
{
var z=document.getElementById("TextBox1").value;
alert(z);
}
</script>
.....
but gives error in browser
tkml123
|
|
|
|
|
Hi,
How you are calling this function?
You can pass TextBox1.ClientId to the function.
Then use that passed variable inside getElementById.
To succeed, we must first believe that we can.
Sherin Iranimose
|
|
|
|
|
hi;
I added html button in "defualt.aspx" to call the javaScript function
<input id="Button1" onclick="ere()" ....
you may notice that the textbox1 is server side control....
plz reply as soon as possible
....
thanks
tkml123
|
|
|
|
|
Ok
Do this
In your page load
Button1.Attributes.Add("onclick", "javascript:ere('" & TextBox1.ClientID & "')")
and
function ere(txt)
{
alert(document.getElementById(txt).value);
}
dont forget to give runat=server to your button.
To succeed, we must first believe that we can.
Sherin Iranimose
|
|
|
|
|
Hi,
FYI, View the Default.aspx page in browser, and View the source (rigth click on page and select View Source). Then you try to locate the ID of your text box. After rendering, the client ID may not be same as the server control ID that you have supplied while developing the page.
So you have required to pass the ClientID of the text box to your Javascript method.
Try Call JavaScript method like, onclick="javascript:function();"
-- modified at 2:59 Wednesday 30th May, 2007
Regards,
Jay
|
|
|
|
|
hi thanks for ur efforts..
but still not working ...
i get the clientID of textbox as u said....
and have tried to
-alert(textbox1.value); not working
-javascript:function(textbox1.value); not working
-javascript:function('textbox1.value'); not working
-alert( document.getElementById("textbox1").value);not working
i really dont know how to solve it
and also tried to search but nothing useful
if you face this problem can you send to me how to solve it ecxattlyyy..
thanks...
tkml123
|
|
|
|
|
Hi,
C# Code
Any Event handler((eg)button click) --> onclick="JavaScript:SomeFunction('" + tbox1.ClientID + "')";
Javascript code:
function SomeFunction(tboxID)
{
tboxID.Value="Test";
}
This will assign the string "Test" to TextBox tbox1. This will works fine. Let me know, if you find any problem.
Regards,
Jay
|
|
|
|
|
thanks thats help somehow
<input id="Button1" .. onclick="test( ctl00_ContentPlaceHolder1_TextBox1 );"/>
..
I passed only client ID to javaScript and works..
but i have tried to pass Textbox1.clientID and gives error in browser.
but i want to ask is the client id will be same in all users that using the same page
thanks
aj123
|
|
|
|
|
I am using Template Fields in which i had taken ImageButton for edit ,Update adn Cancel. when i am clicking the edit imagebutton it goes through
if (e.Row.RowState == DataControlRowState.Edit)
{
ImageButton imageditformtype = (ImageButton)e.Row.FindControl("imgEditFormType");
imageditformtype.Visible = false;
ImageButton imageupdateformtype = (ImageButton)e.Row.FindControl("imgUpdateFormType");
imageupdateformtype.Visible = true;
ImageButton imageditcancelformtype = (ImageButton)e.Row.FindControl("imgEditCancelFormType");
imageditcancelformtype.Visible = true;
}
so the images changes to update and cancel.
But for Alternate rows the rowstate is Alternate and not goes to edit therefore the ImageButtons are not changed
pls help me out with this .
|
|
|
|
|
I am doing simple application in that i am displaying data and Button also there inside the gridview.I want to delete row of gridview when particular button click in the gridview.But i have done this in 2003 but i didn't understand how to modify this below code in 2005.Pls help me
I am getting error in e.Item.ItemIndex in the second line
Protected Sub DelCmd(sender As [Object], e As DataGridCommandEventArgs)
DeleteRow(Me.DataGrid1.DataKeys(e.Item.ItemIndex).ToString())
BindData()
End Sub 'DelCmd
Thanks
|
|
|
|
|
Standard question #2:
What error message do you get?
---
single minded; short sighted; long gone;
|
|
|
|
|
I have one website in that some products are there
like 1000.Then I want to parse that all that items from that site and places one tab file.how to parse the website.plz send me any solutions for this.
|
|
|
|
|
siddisagar wrote: how to parse the website
You mean fetching information from webpage ? I think it's not easy to do this. Try searching with webclient class
|
|
|
|
|
I am trying to create an Excel file with the XMLTextWriter class. I am successfully able to write the excel file with data from dataset in it. But the problem is that the string data being written in Excel is not visible fully in the cells.
I tried the option of AutoFitWidth="1", But it does not comes into effect for String data. I also got some clue for using System.Drawing.Graphics.MeasureString method. But I am not able to use it in Web project.
Can anyone guide me as to how can I fit the width of the string text in excel cell programatically.
If my mind can conceive it, and my heart can believe it, I know I can achieve it.
If my mind can conceive it, and my heart can believe it, I know I can achieve it.
|
|
|
|
|
Hi,
I am facing this problem which I am not sure why this is happening, so here is what happened.
I have this stored procedure
CREATE PROCEDURE dbo.IsValidLogin
(
@username varchar(50) ,
@password varchar(12) ,
@userid int=0 OUTPUT,
@userfullname varchar(50) OUTPUT
)
AS
SELECT @userid=userid, @userfullname=userfullname
FROM tb_user
WHERE useremail=@username
AND userpassword=@password
GO
Then in my ASP.NET C# code, I do this,
//Call stored procedure from database to check validity of username and password
myCommand = new SqlCommand("IsValidLogin", myConnection);
myCommand.CommandType = CommandType.StoredProcedure;
//Declare parameter for input and output of stored procedure
SqlParameter objParam1, objParam2, objParam3, objParam4;
objParam1 = myCommand.Parameters.AddWithValue("@username", SqlDbType.VarChar);
objParam2 = myCommand.Parameters.AddWithValue("@password", SqlDbType.VarChar);
objParam3 = myCommand.Parameters.AddWithValue("@userid", SqlDbType.Int);
objParam4 = myCommand.Parameters.AddWithValue("@userfullname", SqlDbType.VarChar);
objParam1.Direction = ParameterDirection.Input;
objParam2.Direction = ParameterDirection.Input;
objParam3.Direction = ParameterDirection.Output;
objParam4.Direction = ParameterDirection.Output;
objParam1.Value = uname;
objParam2.Value = upwd;
myCommand.ExecuteNonQuery();
if (objParam4.Value == System.DBNull.Value)
{
this.userid = 0;
this.userfullname = "";
}
else
{
this.userid = (int)objParam3.Value;
this.userfullname = (string)objParam4.Value;
}
This is actually a login page which I wanted to retrieve the user id and user full name, but when I login, I got this error message "System.Data.SqlClient.SqlException: Error converting data type varchar to int." It seems that it is the problem of this
"objParam4 = myCommand.Parameters.AddWithValue("@userfullname", SqlDbType.VarChar);" which is converting it to int, I did not make it to change to int but just don't understand why it wanted to convert.
Hope someone experience this before and do let me know why this is happening.
Thanks
J Liang
|
|
|
|
|
Are you sure that your userid field can contain only integer values ? What is the datatype of that field ?
|
|
|
|
|
Hi,
Actually the userid is just an auto-increment value,so it is all interger.
Btw, I got the solution, by changing AddWithValue to Add only.
J Liang
|
|
|
|
|
Hi
See the difference below statements
exec IsValidLogin 'username','123456','sdf'
:If you run the above statement it is throwing error 'Error converting data type varchar to int':
exec IsValidLogin @username='harini',@password='123456',@userfullname='sdf'
:No error in executing this statement:
Solution 1:
Change the order of output parameters as
@username varchar(50) ,<br />
@password varchar(12) , <br />
@userfullname varchar(50) OUTPUT,<br />
@userid int=0 OUTPUT
Solution 2:
Pass maximum value for parameter @userid from code-behind without changing the order of output parameters.
Try any of the above solutions and let me know.
Hope you got it.
Harini
|
|
|
|
|
Harini Krishnaswamy wrote:
exec IsValidLogin 'username','123456','sdf'
:If you run the above statement it is throwing error 'Error converting data type varchar to int':
Yes, that is a different way of getting the same error message, but I don't see the relevance?
---
single minded; short sighted; long gone;
|
|
|
|
|
Hi,
Thanks for the reply, I think this might work too.
I got an earlier post which I switch from AddWithValue to Add as using AddWithValue cause it to add the value and it become me adding 4 integer value.
J Liang
|
|
|
|
|
This is not strange at all.
When you use the AddWithValue method to create parameters, the second argument is not the data type, but the value. Therefore you are creating four parameters with the type int (as int would be the type used to send the enum values to the database).
Use the Add method instead to specify the data type, and also specify the size of the varchar fields:
objParam1 = myCommand.Parameters.Add("@username", SqlDbType.VarChar, 50);<br />
objParam2 = myCommand.Parameters.Add("@password", SqlDbType.VarChar, 12);<br />
objParam3 = myCommand.Parameters.Add("@userid", SqlDbType.Int);<br />
objParam4 = myCommand.Parameters.Add("@userfullname", SqlDbType.VarChar, 50);
---
single minded; short sighted; long gone;
|
|
|
|
|
Hey,
Thanks, this way works well, didnt really understood the difference of Add and AddWithValue until now.
J Liang
|
|
|
|
|
|
Hello, first let me say that I am a newbie to .Net, so please be gentle. I've been registered on this site for a while, but I recently started by first .Net developer job, so I'll probably be posting here frequently now!
I am developing a custom server control to be used for a Web Part. All of the controls are created dynamically (not using the designer). I am gathering several user input fields via a DetailsView control. I need to validate the user input, but all of the examples I can find use a Template added to the HTML. Since I am not using the designer, I don't have the HTML, except for what I render myself.
So my question is, how do I render the HTML in such a way as to be able to add user input validation?
Thanks for your help!
|
|
|
|
|
I am trying cascadingdropdown with ajax control. On my form i add 1
combobox and the cascadingdropdown control. When I run the page the
combobox displays the Select... and no options except for
[Method Error 500]
Please help me.
Here is my web service code.
using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Collections.Generic;
using AjaxControlToolkit;
using System.Data;
using System.Data.SqlClient;
///
/// Summary description for FoodService
///
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService]
public class FoodService : System.Web.Services.WebService
{
public FoodService()
{
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
// public CascadingDropDownNameValue[] GetItemsByCategoryID(string
KnownCategoryValues, string category)
// {
// string[] _categoryValues = KnownCategoryValues.Split(':',
';');
// int _foodID = Convert.ToInt32(_categoryValues[1]);
// List<cascadingdropdownnamevalue> _foodItems = new
List<cascadingdropdownnamevalue>();
// dsFoodTableAdapters.tbparentTableAdapter _foodAdapter =
//new dsFoodTableAdapters.tbparentTableAdapter();
// foreach (DataRow _row in _foodAdapter.GetFoodData())
// {
// _foodItems.Add(new
CascadingDropDownNameValue(_row["category"].ToString(),
_row["categoryID"].ToString()));
// }
// // convert to array and return the vlaues
// return _foodItems.ToArray();
// }
public CascadingDropDownNameValue[] GetItemsByCategoryID(string
KnownCategoryValues)
{
string[] _categoryValues = KnownCategoryValues.Split(':',
';');
int _foodID = Convert.ToInt32(_categoryValues[1]);
List<cascadingdropdownnamevalue> _foodItems = new
List<cascadingdropdownnamevalue>();
// dsFoodTableAdapters.tbparentTableAdapter _foodAdapter =
//new dsFoodTableAdapters.tbparentTableAdapter();
dsFoodItemsTableAdapters.tbChildTableAdapter _foodAdapter =
new dsFoodItemsTableAdapters.tbChildTableAdapter();
foreach (DataRow _row in _foodAdapter.GetData(_foodID))
{
_foodItems.Add(new
CascadingDropDownNameValue(_row["subcategory"].ToString(),
_row["subcategoryID"].ToString()));
}
// convert to array and return the vlaues
return _foodItems.ToArray();
}
}
#######################################
Below is the code for aspx page
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default3.aspx.cs" Inherits="Default3" %>
<%@ Register Assembly="AjaxControlToolkit"
Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<title>Untitled Page
<asp:scriptmanager id="ScriptManager1" runat="server">
<asp:dropdownlist id="DropDownList1" runat="server"
datasourceid="ObjectDataSource1"
="" datatextfield="category" datavaluefield="categoryID">
<asp:objectdatasource
id="ObjectDataSource1" runat="server"
oldvaluesparameterformatstring="original_{0}"
="" selectmethod="GetFoodData"
typename="dsFoodTableAdapters.tbparentTableAdapter">
<asp:dropdownlist id="DropDownList2" runat="server">
<cc1:cascadingdropdown id="CascadingDropDown1" runat="server"
category="tbChild" loadingtext="please wait"
parentcontrolid="DropDownList1" prompttext="please subcategory"
servicemethod="GetItemsByCategoryID" targetcontrolid="DropDownList2">
seema
|
|
|
|