|
thx can you plz give me some code? how to send a stream to a .doc or .xls file?
BiG RaLpH
|
|
|
|
|
|
hi all
i have some values on html page in javascript. i want to get that values in C#. how to do that.
I tried displaying it on a label, and retreave it from there.
but it is displaying the value but label.text is empty. no value in label text.
|
|
|
|
|
P_Elza wrote: I tried displaying it on a label, and retreave it from there.
Yes, that will work, as would putting it in a hidden field that is a server control. What does your code look like ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
This is the function in javascript
function display()<br />
{<br />
var localpath1 = document.getElementById('lblerr');<br />
lblerr.innerText = localpath;<br />
}
it is diplaying the value on label. lblerr is the id of label. am calling this function on pageload
but when i try to get the value using lblerr.text, it is showing null.
y is it so?
how to get value on the label
|
|
|
|
|
i think this value that you are initialzing in javascript won't persist.
Do one thing Add hidden variable runat server and assign value to that hidden varaible and use that hidden varaible at server side like this
var label1=document.getElementById('hidden');<br />
<br />
label1.value="Sandeep";<br />
and at the server side just get the value from it
hidden.Value that will return you string
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
i had tried this one also previously.
error was occuring
the error is
System.NullReferenceException:Object reference not set to an instance of an object
what is this?
how to rectify this.
am new to .net. thats y am asking all these questions.
please dont feel bad.
|
|
|
|
|
It means that you are using the object whose instance is not creaetd yet
It will also give the line number. check the line number
Which version of ASP.nET are you using ?
Please pest the code
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
on line number i have writen
string val=txtHidden.Value.ToString();
eat is wrong in this?
while debuging it is showing the value of txthiden as
txtHidden: <undefined value>: System.Web.UI.HtmlControls.HtmlInputHidden
am using .net 2003
|
|
|
|
|
OK don't add ToString();
just add
string val=txtHidden.Value;
And be sure that txtHidden is decalared in your application such as
System.Web.UI.HtmlControls.HtmlInputHidden txtHidden;
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
that all thing i have written
and i have tried this as
string val=txtHidden.Value; also
befor. it ididnt work that time so i added it to string();
i dont know wat is wrong in my code and y it is not working.
why it is taking txtHiddenas "undefined"? i have defined it previously na?
|
|
|
|
|
Check the id of the hidden control in aspx page and aspx.cs both should be identical.
Could you post your whole page ?
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Text;
using System.IO;
using System.Data.SqlClient;
namespace Web
{
public class _3B2Temp : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button btnclick;
protected System.Web.UI.WebControls.Label lblmsg;
protected System.Web.UI.WebControls.Label lblerr;
protected System.Web.UI.HtmlControls.HtmlInputHidden txtHidden;
private void Page_Load(object sender, System.EventArgs e)
{
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}
private void InitializeComponent()
{
this.btnclick.Click += new System.EventHandler(this.btnclick_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void btnclick_Click(object sender, System.EventArgs e)
{
string val=txtHidden.Value;
}
}
}
</code>
hope this is enough
|
|
|
|
|
I tried this in
private void Page_Load(object sender, System.EventArgs e)
{} also....
please dont stop replaing in between.
|
|
|
|
|
Please be sure that txtHidden value is assigned in aspx
Code looks right check my code
this is javascript function
function HideContent()
{
var hiddenVar=document.getElementById('hidden');
hiddenVar.value="Sandeep";
}
And here is the .cs file code
protected void Page_Load(object sender, EventArgs e)
{
Button1.Attributes.Add("onclick", "javascript:HideContent();");
}
protected void Button1_Click(object sender, EventArgs e)
{
if (!String.IsNullOrEmpty(hidden.Value))
{
TextBox1.Text = hidden.Value;
}
}
It is working boss in my machine
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
thank u boss
its working now
thanks a lot
|
|
|
|
|
P_Elza wrote: document.getElementById('lblerr');
If this works, odds are that lblerr is not a server control. A server control invariably has a longer client side Id than it's server side one.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Christian Graus wrote: odds are that lblerr is not a server control
I didnt understand what u mean. I said this code is not working. and showing error
|
|
|
|
|
Try this
if(Request.querystring["Value"]!=null)<br />
{<br />
Idval=Request.querystring["Value"];<br />
label1.Text=Idval; <br />
} <br />
|
|
|
|
|
What if he wants the value in same page when postback occurs ?
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
I tryed this but
Kasi Viswanathan wrote: Request.querystring is showing error. I couldent rectify this.
th error is
'System.Web.HttpRequest' does not contain a definition for 'querystring'
|
|
|
|
|
It may be get by two way
1. Make hidden field and assign your javascript values to that field using javascript. AND then used that hidden field in code behind.
2. Use cookies to get/set values from javascript and codebehind. B'cz as you may know cookies can be operate by javascript and codebehind both side.
Prakash Samariya
|
|
|
|
|
How to bind the values to arraylist and hashtable...,
Ex:
Here i am binding some arraylist and hashtable like this:
Dim _Text As ArrayList = New ArrayList
_Text.Add("Name1")
_Text.add("Name2")
Dim _SubTabText As Hashtable = New Hashtable
_Text = New ArrayList
_Text.Add("Name1")
_Text.Add("Name2")
_SubTabText.Add(1, _Text)
Same things i like to bind using query...,
This is my query:
Select id,name from employee
The above query name have to bind in arraylist
similarly in hashtable id has been key and name has been value...,
How to do that???,
Advance thanks...,
Regards,
Magi
|
|
|
|
|
try this code i am not sure..
_Text = New ArrayList
_Text.Add("Name1")
_Text.Add("Name2")
Controlid.DataSource=_Text
Controlid.DataBind()
|
|
|
|
|
try this code
for hash Table..
dim ss=New Hashtable
ss.Add("N","Name1")
ss.Add("S","Name2")
controlid.DataSource=ss
controlid.DataValueField="id"
controlid.DataTextField="name"
controlid.DataBind()
|
|
|
|