Wednesday, March 28, 2012
text case
I have just started using .Net . In VB 6.0 the text case of a variable would change automatically based on the declaration.
This doesn't seem to be the case in .Net. Is that correct ? Do I have check/uncheck some options in the menu to make the software do this ?
ThanksMine does when I use the Code Behind section of ASP.NET. If your just putting the ASP.NET code on the aspx page itself it may not correct the "Case" of the variables and stuff. I could be wrong, but i'm pretty sure that is your problem.
How do I use the code-behind section ?
Thanks
If your using the Visual Studio.Net IDE then to get at the code behind just double click the form like you would in VB6.
There maybe a way to use Code-Behind if your not using the VS.net IDE but I don't know how to do that.
Monday, March 26, 2012
text for asp:label from session
from a session variable. Something like:
<asp:label text="<%# session("ClientName") %>" runat="server"/
This doesn't work, but is there a way to have it do this with out having to
set up code in the Page_Load sub to accomplish this?
Thanks,
TomTom:
Create a custom control:
public class ClientName
Inherits Label
public override sub Render(Writer as HtmlTextWriter)
if not session("ClientName") is nothing then
Text = cstr(Session("ClientName"))
else
Text = "Anonymous"
end if
myBase.Render(writer)
end sub
end class
not tested, but something like that ought to work.
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"tshad" <tscheiderich@.ftsolutions.com> wrote in message
news:%23qeKbChCFHA.464@.TK2MSFTNGP15.phx.gbl...
> How do I set up text (or can I) set up a label to automatically pull in
text
> from a session variable. Something like:
> <asp:label text="<%# session("ClientName") %>" runat="server"/>
> This doesn't work, but is there a way to have it do this with out having
to
> set up code in the Page_Load sub to accomplish this?
> Thanks,
> Tom
text for asp:label from session
from a session variable. Something like:
<asp:label text="<%# session("ClientName") %>" runat="server"/>
This doesn't work, but is there a way to have it do this with out having to
set up code in the Page_Load sub to accomplish this?
Thanks,
TomTom:
Create a custom control:
public class ClientName
Inherits Label
public override sub Render(Writer as HtmlTextWriter)
if not session("ClientName") is nothing then
Text = cstr(Session("ClientName"))
else
Text = "Anonymous"
end if
myBase.Render(writer)
end sub
end class
not tested, but something like that ought to work.
Karl
MY ASP.Net tutorials
http://www.openmymind.net/
"tshad" <tscheiderich@.ftsolutions.com> wrote in message
news:%23qeKbChCFHA.464@.TK2MSFTNGP15.phx.gbl...
> How do I set up text (or can I) set up a label to automatically pull in
text
> from a session variable. Something like:
> <asp:label text="<%# session("ClientName") %>" runat="server"/>
> This doesn't work, but is there a way to have it do this with out having
to
> set up code in the Page_Load sub to accomplish this?
> Thanks,
> Tom
>
Thursday, March 22, 2012
textbod id changed automatically
I've a master page, and the content place i'v a page which has a text box
name tbCity. I would like to use javascript to find out that was blank or
not.
When i look at the sourcecode th text box id was chagned to
ctl00_Main_tbCity
why is it like this.
ThanksHello Ganesh
> I've a master page, and the content place i'v a page which has a text box
> name tbCity. I would like to use javascript to find out that was blank or
> not.
document.getElementById(<Control.ClientID> ).value == '';
> When i look at the sourcecode th text box id was chagned to
> ctl00_Main_tbCity
> why is it like this.
On the server side, ASP.NET has features like, nesting Controls, Namespaces,
etc..
that help to have consistente IDs. That means also, you can have more then
on of the same IDs on a page.
When ASP.NET rendered the code for viewing in a Html Browser, there are no
features like on the server side.
Here you can`t have more then one identic ID for a control.
So ASP.NET generates automatically IDs and Names where based on the control
hierarchy.
The <Control>.ClientID represents the ID Attribute on the clientside.
The <Control>.UniqueID represents the NAME Attribute on the clientside.
I have written a german article about identification of ASP.NET Controls.
Maybe you`r be able to understand the Google Translated Page:
-
http://translate.google.com/transla...aspnetzone.de/ - ASP.NET Zone, die ASP.NET Community
http://www.aspnetzone.de/blogs/peterbucher/ - Auf den Spuren von .NET
Hi Peter,
Thanks for your help.
"Peter Bucher [MVP]" <peter.bucher@.aspnetzone.de> wrote in message
news:OxXvYyf0HHA.1184@.TK2MSFTNGP04.phx.gbl...
> Hello Ganesh
>
> document.getElementById(<Control.ClientID> ).value == '';
>
> On the server side, ASP.NET has features like, nesting Controls,
> Namespaces, etc..
> that help to have consistente IDs. That means also, you can have more then
> on of the same IDs on a page.
> When ASP.NET rendered the code for viewing in a Html Browser, there are no
> features like on the server side.
> Here you can`t have more then one identic ID for a control.
> So ASP.NET generates automatically IDs and Names where based on the
> control hierarchy.
> The <Control>.ClientID represents the ID Attribute on the clientside.
> The <Control>.UniqueID represents the NAME Attribute on the clientside.
> I have written a german article about identification of ASP.NET Controls.
> Maybe you`r be able to understand the Google Translated Page:
> -
> http://translate.google.com/transla...aspnetzone.de/ - ASP.NET Zone, die ASP.NET Community
> http://www.aspnetzone.de/blogs/peterbucher/ - Auf den Spuren von .NET
"Ganesh" <gsganesh@.yahoo.com> wrote in message
news:OO75qTf0HHA.1100@.TK2MSFTNGP06.phx.gbl...
> I've a master page, and the content place i'v a page which has a text box
> name tbCity. I would like to use javascript to find out that was blank or
> not.
> When i look at the sourcecode th text box id was chagned to
> ctl00_Main_tbCity
if (document.getElementById(<%=tbCity.ClientID%> ).value == '')
{
// do something
}
> why is it like this.
To guarantee uniqueness of ID.
Mark Rae
ASP.NET MVP
http://www.markrae.net
Textbox
I need to set the textbox to allow numeric input only and it automatically display with thousand separator and 2 decimal symbol.. how to do this?
Please help
Thanks
WinanjayaThere are a few ways to do it. there are validator controls that will check tha value of your text box client side or you can validate on the server side using regular expressions.
public static bool Validate(string DirtyString, string RegularExpresion)
{
bool passed = true;
System.Web.HttpContext curr = System.Web.HttpContext.Current;
string currcell = curr.Server.HtmlEncode(DirtyString);
currcell = currcell.Trim();
if (passed == PassedFilter(currcell,RegularExpresion))
{
return true;
}
else
{
return false;
}
}
public static bool PassedFilter(string DirtyString, string FilterExp)
{
string cleanstring = "";
foreach (Match charMatch in System.Text.RegularExpressions.Regex.Matches(DirtyString, FilterExp))
{
cleanstring = cleanstring + charMatch;
}
if (cleanstring.Length == DirtyString.Length)
{
return true;
}
else
{
return false;
}
}
This is the server side way. Pass the string you want to validate and the regular expression to validate against it.