Script

  • Thread starter Thread starter simon
  • Start date Start date
S

simon

if I have on page:

<asp:label id="Label1"></asp:label>

and I can't get its value on client script:

<script language="vbscript">
sub test()
msgbox form1.label1.text
end sub
</script>

If I use instead of this <input type=...>
I can read it's value in client script but I can't access it on code behind
page.

I have to set the start value on the page_onload event and than change it by
client script.
How to do that?

Thank you,
Simon
 
Create your label as a server-side control - <asp:label id="Label1"
runat="Server">{Label1}</asp:label>

You can set the default value of this label from the codebehind file in the
Page_Load function, using Label1.Text = "Initial Value"

To edit this value from client side code you can use the following code.

function changeText(newtext)
{
var e = document.getElementById("Label1");
e.innerText = newtext;
}

<input type="button" value="Change Text" onClick="changeText('New Value')">

Hope this helps,

Mun
 
I have timepicker activeX.I can set it's default value on codebehind
page_onload. It doesn't work.
So I have to use the script: window_onload, read the label value and set the
default value of activeX.
Is'n simplier the old asp way where I can set the default value while the
page is creating?

Why <%request.querystring%> on the aspx page doesn't working? It works only
If i use it on codebehind.

Do you have some timePicker control which works on codebehind?
There is one but it works only in forms not in web forms.

Thank you,
Simon
 
I'm pretty sure there's a web-based version of the DateTimePicker control,
though it's not as nice as the windows form one.

To use the QueryString directly in your page, what you can do is create a
public variable and then reference this variable in your ASPX page.

[C# - CodeBehind]

string something;

Page_Load(object sender, System.EventArgs e)
{
something = Request.QueryString.Get("something");
}

[ASPX]

<b>Value of something: </b> <%=something%>

[Usage]

WebForm1.aspx?something=Hello+World


Hope this helps,

Mun
 
Thank you for your answer.

I didn't found any similar web-based version of the DateTimePicker control,
with minutes and seconds.
I should create one by my self or use exsisting activeX, probably the last
one:)

If you found some, please notice me

Thank you,
Simon

Munsifali Rashid said:
I'm pretty sure there's a web-based version of the DateTimePicker control,
though it's not as nice as the windows form one.

To use the QueryString directly in your page, what you can do is create a
public variable and then reference this variable in your ASPX page.

[C# - CodeBehind]

string something;

Page_Load(object sender, System.EventArgs e)
{
something = Request.QueryString.Get("something");
}

[ASPX]

<b>Value of something: </b> <%=something%>

[Usage]

WebForm1.aspx?something=Hello+World


Hope this helps,

Mun




simon said:
I have timepicker activeX.I can set it's default value on codebehind
page_onload. It doesn't work.
So I have to use the script: window_onload, read the label value and set the
default value of activeX.
Is'n simplier the old asp way where I can set the default value while the
page is creating?

Why <%request.querystring%> on the aspx page doesn't working? It works only
If i use it on codebehind.

Do you have some timePicker control which works on codebehind?
There is one but it works only in forms not in web forms.

Thank you,
Simon
 
Back
Top