Showing posts with label html. Show all posts
Showing posts with label html. Show all posts

Saturday, March 31, 2012

Set a condition before following a hyperlink

In straightforward html I have used the following:-

<a onClick="return checkpass(Checkit.PassToForm.value);" href="http://links.10026.com/?link=myweb3/members.htm">Continue

where checkpass is a function that returns true or false and it has to be true before the user can access the next page.

Validation controls would not be an answer in this particular instance

I have not been able to do the same sort of thing in ASP. onclick = "return Somefunction"; href etc produces an error message "Somefunction isundefined"


In Asp, if the OnClick event is already defined for the webcontrol, then it is expecting a C# function handler. In this case, you will need to use OnClientClick.

I would suggest using a LinkButton. This will ensure that people are validated when going to the next page, cause if javascript is disabled then the link button wont redirect the user.

<asp:LinkButton ID="lb" runat="server" Text="Gohere" OnClientClick="return checkpass("myvalue")" />


You would need preventDefault.http://developer.mozilla.org/en/docs/DOM:event.preventDefault

But it is not supported in old browsers.


Hi

I think the checkpass function is some sort of a client side scripting function (probably javascript). If that is right I would suggest you to open the new page from the javascript function itself rather than using href.

Hope this helps to solve your problem

Good LuckYes

Regards

Vineed


Hi,

Mulozi:

<a onClick="return checkpass(Checkit.PassToForm.value);" href="http://links.10026.com/?link=myweb3/members.htm">Continue

You can redirect the page in the javascript function itself. So your fucntion checks the details and if correct it will transfer to another page.

use the below...

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript" language="javascript">
function checkDetails()
{
if(document.getElementById("txt").value != "")
{
window.location.href="default2.aspx";
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txt" runat="server"></asp:TextBox><br />
<a onclick="checkDetails();" href="http://links.10026.com/?link=http://forums.asp.net/AddPost.aspx?ReplyToPostID=1967328&Quote=False#"> Hi</a></div>
</form>
</body>
</html>


Thanks.

I should have mentioned that I am using VB for this application. Sorry to have put you to the trouble.

I seem to have succeeded in a previous application which used Javascript.

I have to use VB for this one and am trying to find the VB equivalent.

Thee must be an equivalent somehow using VB

I should also have mentioned that I have been using Visual Web Developer 2008 express edition


Thanks.

I haven't been able to succeed with this either

I should have mentioned that I am using VB for this application. Sorry to have put you to the trouble.

I seem to have succeeded in a previous application which used Javascript. and the previous example was Javascript .

I have to use VB for this one and am trying to find the VB equivalent.

There must be an equivalent somehow using VB

Can I not run a script from the command button which would include a conditional go to URL ... ?

I should also have mentioned that I have been using Visual Web Developer 2008 express edition

Any further thoughts gratefully received.


Thanks.

I presume preventDefault is Javascript

I should have mentioned that I am using VB for this application.

I seem to have succeeded in a previous application which used Javascript. and the previous example was Javascript .

I have to use VB for this one and am trying to find the VB equivalent.

There must be an equivalent somehow using VB

Can I not run a script from the command button which would include a conditional go to URL ... ? I have not found a way of doing it, but this must be a common enough requirement.

I should also have mentioned that I have been using Visual Web Developer 2008 express edition

Any further thoughts gratefully received.


Hi,

Are you trying to execute the function on the client-side or server side. If you can execute it on the server side, then instead of a hyperlink use a linkbutton and on the click event of it check the condition that you are looking out for and use Response.Redirect to the new page. That should possibly solve the problem.

Hope this solves your problem

Good LuckYes

Regards

Vineed

Thursday, March 29, 2012

Set Code Behind Property from Javascript / link?

I got a property in my code behind, nl "Language" with Get and Set accessors.

On my form I want to put a link (html, not asp) who's target is a javascript in my <head> section.
Then I want this Javascript to set the value of my Language property, and in the Set accessor for the property, do some stuff.

Is it possible to set the property in the code behind from your page? Maybe i should just use an asp label running on the server, but I'm trying to see how far i can stay away from anything causing a postback.The Language property exists in the codebehind. You do realize that at some point, you will have to have a postback so that the property can be assigned that value and perform whatever actions it wants to perform. Get it?

You will eventually have to use some sort of a server-side control for this. Here's what I would suggest.

Add a hidden field to your page. When the user clicks on the hyperlink, the javascript function assigns a value to that hidden field. When the page posts back, in the page load event, assign the value of the hidden field to your property. Then let the property do whatever with it.

No, you cannot avoid the postback as far as you've described your setup.
Actually I was stupid anyhow. When hte language change, I got to reload the form with the different language.

I never use hidden fields though. Nevermind

Thanks for reply M.
No prob.
Just been thinking.
What if one do want to set a code behind property from the page?
What if you do want to call a code behind fucntion from a javascript, sitting in hte head section, called by for instance a link clicked?
The answer to your first question is above ^^

The answer to your second question is a little complex. You will need to use javascript to force a postback. You can do this in one of two ways. For example, if you want to call a button's click event, you can call it like

document.getElementById('buttonid').click();

The second way to do this is quite generic. You can use javascript to force a postback.

http://weblogs.asp.net/mnolton/archive/2003/06/04/8260.aspx

Monday, March 26, 2012

Set error level in Visual Studio 2005?

I have a website I'm working on in VS 2005. Now a lot of the pages were done in Dreamweaver, but all the HTML errors that popup in the error list are really peeing me off. These errors are irrelevant, I couldn't really care if Element 'html' is missing required attribute 'xmlns'.

How do I stop these errors from displaying? I only want serious errors, I can't seem to find how to do it in the options, and help doesnt offer any suggestions either.

ThanksLook for the page's TargetSchema property.
Is there not something I can set at the application level? I have like 300 pages in my project...
Best you can do: They are warnings, ignore them.
Thing is, the 'serious' errors will prevent the application from compiling anyways. You'll see them with the exclamation mark next to them.

Thursday, March 22, 2012

Set HTML Attribute In Page_Load Event

I want to be able to set an attribute of the HTML object in the form's
Page_Load event. I can't see how to do this. The main problem is that I
can't see how to access the HTML object from this event. Can anyone help ?

BenBen,

Forthe element you need to specify runat=server and id=myHtml. Then VS will
define the element for you in code-behind as the page's protected member. In
any page method you can set an attribute as (c# syntax):

myHtml.Attributes["myAttribute"]="my string";

Eliyahu

"Ben Foster" <ben.foster@.nospam.com> wrote in message
news:OozPcRBGFHA.2180@.TK2MSFTNGP10.phx.gbl...
> I want to be able to set an attribute of the HTML object in the form's
> Page_Load event. I can't see how to do this. The main problem is that I
> can't see how to access the HTML object from this event. Can anyone help ?
> Ben
Eliyahu,

That works fine. Thanks.

Ben

"Eliyahu Goldin" <removemeegoldin@.monarchmed.com> wrote in message
news:%23TIxNYBGFHA.3244@.TK2MSFTNGP15.phx.gbl...
> Ben,
> Forthe element you need to specify runat=server and id=myHtml. Then VS
> will
> define the element for you in code-behind as the page's protected member.
> In
> any page method you can set an attribute as (c# syntax):
> myHtml.Attributes["myAttribute"]="my string";
> Eliyahu
> "Ben Foster" <ben.foster@.nospam.com> wrote in message
> news:OozPcRBGFHA.2180@.TK2MSFTNGP10.phx.gbl...
>> I want to be able to set an attribute of the HTML object in the form's
>> Page_Load event. I can't see how to do this. The main problem is that I
>> can't see how to access the HTML object from this event. Can anyone help
>> ?
>>
>> Ben
>>
>>

Set HTML Attribute In Page_Load Event

I want to be able to set an attribute of the HTML object in the form's
Page_Load event. I can't see how to do this. The main problem is that I
can't see how to access the HTML object from this event. Can anyone help ?
BenBen,
Forthe element you need to specify runat=server and id=myHtml. Then VS will
define the element for you in code-behind as the page's protected member. In
any page method you can set an attribute as (c# syntax):
myHtml.Attributes["myAttribute"]="my string";
Eliyahu
"Ben Foster" <ben.foster@.nospam.com> wrote in message
news:OozPcRBGFHA.2180@.TK2MSFTNGP10.phx.gbl...
> I want to be able to set an attribute of the HTML object in the form's
> Page_Load event. I can't see how to do this. The main problem is that I
> can't see how to access the HTML object from this event. Can anyone help ?
> Ben
>
Eliyahu,
That works fine. Thanks.
Ben
"Eliyahu Goldin" <removemeegoldin@.monarchmed.com> wrote in message
news:%23TIxNYBGFHA.3244@.TK2MSFTNGP15.phx.gbl...
> Ben,
> Forthe element you need to specify runat=server and id=myHtml. Then VS
> will
> define the element for you in code-behind as the page's protected member.
> In
> any page method you can set an attribute as (c# syntax):
> myHtml.Attributes["myAttribute"]="my string";
> Eliyahu
> "Ben Foster" <ben.foster@.nospam.com> wrote in message
> news:OozPcRBGFHA.2180@.TK2MSFTNGP10.phx.gbl...
>

Set html table width at run time (in code)

Hi
How can I get a html control in my code?
I have a html table that I want the width is defined in code at run time,
i.e., I have this table and I have a datagrid. This datagrid have a variable
width because the number of columns depends of something that I have (that
is not important for this). Now, what I want is that the html table have
always the same width of my datagrid because of alignment of both.
NOTE: I must have (and want) the datagrid width variable and not fixed
Programming ASP.NET with VB.NET
Thank's (if you try to help me)
Hope this help you (if I try to help you)
rucaset its attribute runat=server, but you'll probably still have problems
while tables align width depending on its content... You can hardly create
different tables with same width. The only chance is when content never
exceedes desired table (or better said cell) width.
RobertK
{ Clever? No just smart. }
"ruca" <ruuca@.iol.pt> wrote in message
news:e4d176wbEHA.3148@.TK2MSFTNGP10.phx.gbl...
> Hi
> How can I get a html control in my code?
> I have a html table that I want the width is defined in code at run time,
> i.e., I have this table and I have a datagrid. This datagrid have a
variable
> width because the number of columns depends of something that I have (that
> is not important for this). Now, what I want is that the html table have
> always the same width of my datagrid because of alignment of both.
> NOTE: I must have (and want) the datagrid width variable and not fixed
>
> --
> Programming ASP.NET with VB.NET
> Thank's (if you try to help me)
> Hope this help you (if I try to help you)
> ruca
>
Thanks
Now, how can I get the widht value at run time of a datagrid?
I have this:
Dim dgPx As Unit
dgPx = myDataGrid.Width()
But dgPx.Value does not have the value of the grid after binding grid.
Can you help?
Programming ASP.NET with VB.NET
Thank's (if you try to help me)
Hope this help you (if I try to help you)
ruca
"Robert Koritnik" <robert.koritnik.removethis@.avtenta.si> escreveu na
mensagem news:%23hnurAxbEHA.2816@.TK2MSFTNGP11.phx.gbl...
> set its attribute runat=server, but you'll probably still have problems
> while tables align width depending on its content... You can hardly create
> different tables with same width. The only chance is when content never
> exceedes desired table (or better said cell) width.
> --
> RobertK
> { Clever? No just smart. }
> "ruca" <ruuca@.iol.pt> wrote in message
> news:e4d176wbEHA.3148@.TK2MSFTNGP10.phx.gbl...
time,
> variable
(that
>
You will have to set that. I told you in my first answer this is a tough
one. The best suggestion I could give you is to put both (table and
Datagrid) inside another table set both control's width to 100%. They would
perfectly align and everything will depend on the width of the containing
table cell.
And you probably won't have to wory about widths of both parts of the
page... Or better said tables, while a datagris is also a table.
RobertK
{ Clever? No just smart. }
"ruca" <ruuca@.iol.pt> wrote in message
news:ekMCZTxbEHA.1048@.tk2msftngp13.phx.gbl...
> Thanks
> Now, how can I get the widht value at run time of a datagrid?
> I have this:
> Dim dgPx As Unit
> dgPx = myDataGrid.Width()
> But dgPx.Value does not have the value of the grid after binding grid.
> Can you help?
>
> --
> Programming ASP.NET with VB.NET
> Thank's (if you try to help me)
> Hope this help you (if I try to help you)
> ruca
> "Robert Koritnik" <robert.koritnik.removethis@.avtenta.si> escreveu na
> mensagem news:%23hnurAxbEHA.2816@.TK2MSFTNGP11.phx.gbl...
create
> time,
> (that
have
>
One doesn't do this sort of things in the code. Put both the table and the
grid in another table as it's been suggested in another reply.
Eliyahu
"ruca" <ruuca@.iol.pt> wrote in message
news:e4d176wbEHA.3148@.TK2MSFTNGP10.phx.gbl...
> Hi
> How can I get a html control in my code?
> I have a html table that I want the width is defined in code at run time,
> i.e., I have this table and I have a datagrid. This datagrid have a
variable
> width because the number of columns depends of something that I have (that
> is not important for this). Now, what I want is that the html table have
> always the same width of my datagrid because of alignment of both.
> NOTE: I must have (and want) the datagrid width variable and not fixed
>
> --
> Programming ASP.NET with VB.NET
> Thank's (if you try to help me)
> Hope this help you (if I try to help you)
> ruca
>

Set html table width at run time (in code)

Hi

How can I get a html control in my code?
I have a html table that I want the width is defined in code at run time,
i.e., I have this table and I have a datagrid. This datagrid have a variable
width because the number of columns depends of something that I have (that
is not important for this). Now, what I want is that the html table have
always the same width of my datagrid because of alignment of both.

NOTE: I must have (and want) the datagrid width variable and not fixed

--
Programming ASP.NET with VB.NET
Thank's (if you try to help me)
Hope this help you (if I try to help you)
rucaset its attribute runat=server, but you'll probably still have problems
while tables align width depending on its content... You can hardly create
different tables with same width. The only chance is when content never
exceedes desired table (or better said cell) width.

--
RobertK
{ Clever? No just smart. }

"ruca" <ruuca@.iol.pt> wrote in message
news:e4d176wbEHA.3148@.TK2MSFTNGP10.phx.gbl...
> Hi
> How can I get a html control in my code?
> I have a html table that I want the width is defined in code at run time,
> i.e., I have this table and I have a datagrid. This datagrid have a
variable
> width because the number of columns depends of something that I have (that
> is not important for this). Now, what I want is that the html table have
> always the same width of my datagrid because of alignment of both.
> NOTE: I must have (and want) the datagrid width variable and not fixed
>
> --
> Programming ASP.NET with VB.NET
> Thank's (if you try to help me)
> Hope this help you (if I try to help you)
> ruca
Thanks
Now, how can I get the widht value at run time of a datagrid?

I have this:
Dim dgPx As Unit
dgPx = myDataGrid.Width()

But dgPx.Value does not have the value of the grid after binding grid.
Can you help?

--
Programming ASP.NET with VB.NET
Thank's (if you try to help me)
Hope this help you (if I try to help you)
ruca

"Robert Koritnik" <robert.koritnik.removethis@.avtenta.si> escreveu na
mensagem news:%23hnurAxbEHA.2816@.TK2MSFTNGP11.phx.gbl...
> set its attribute runat=server, but you'll probably still have problems
> while tables align width depending on its content... You can hardly create
> different tables with same width. The only chance is when content never
> exceedes desired table (or better said cell) width.
> --
> RobertK
> { Clever? No just smart. }
> "ruca" <ruuca@.iol.pt> wrote in message
> news:e4d176wbEHA.3148@.TK2MSFTNGP10.phx.gbl...
> > Hi
> > How can I get a html control in my code?
> > I have a html table that I want the width is defined in code at run
time,
> > i.e., I have this table and I have a datagrid. This datagrid have a
> variable
> > width because the number of columns depends of something that I have
(that
> > is not important for this). Now, what I want is that the html table have
> > always the same width of my datagrid because of alignment of both.
> > NOTE: I must have (and want) the datagrid width variable and not fixed
> > --
> > Programming ASP.NET with VB.NET
> > Thank's (if you try to help me)
> > Hope this help you (if I try to help you)
> > ruca
You will have to set that. I told you in my first answer this is a tough
one. The best suggestion I could give you is to put both (table and
Datagrid) inside another table set both control's width to 100%. They would
perfectly align and everything will depend on the width of the containing
table cell.

And you probably won't have to wory about widths of both parts of the
page... Or better said tables, while a datagris is also a table.

--
RobertK
{ Clever? No just smart. }

"ruca" <ruuca@.iol.pt> wrote in message
news:ekMCZTxbEHA.1048@.tk2msftngp13.phx.gbl...
> Thanks
> Now, how can I get the widht value at run time of a datagrid?
> I have this:
> Dim dgPx As Unit
> dgPx = myDataGrid.Width()
> But dgPx.Value does not have the value of the grid after binding grid.
> Can you help?
>
> --
> Programming ASP.NET with VB.NET
> Thank's (if you try to help me)
> Hope this help you (if I try to help you)
> ruca
> "Robert Koritnik" <robert.koritnik.removethis@.avtenta.si> escreveu na
> mensagem news:%23hnurAxbEHA.2816@.TK2MSFTNGP11.phx.gbl...
> > set its attribute runat=server, but you'll probably still have problems
> > while tables align width depending on its content... You can hardly
create
> > different tables with same width. The only chance is when content never
> > exceedes desired table (or better said cell) width.
> > --
> > RobertK
> > { Clever? No just smart. }
> > "ruca" <ruuca@.iol.pt> wrote in message
> > news:e4d176wbEHA.3148@.TK2MSFTNGP10.phx.gbl...
> > > Hi
> > > > How can I get a html control in my code?
> > > I have a html table that I want the width is defined in code at run
> time,
> > > i.e., I have this table and I have a datagrid. This datagrid have a
> > variable
> > > width because the number of columns depends of something that I have
> (that
> > > is not important for this). Now, what I want is that the html table
have
> > > always the same width of my datagrid because of alignment of both.
> > > > NOTE: I must have (and want) the datagrid width variable and not fixed
> > > > > --
> > > Programming ASP.NET with VB.NET
> > > Thank's (if you try to help me)
> > > Hope this help you (if I try to help you)
> > > ruca
> >
One doesn't do this sort of things in the code. Put both the table and the
grid in another table as it's been suggested in another reply.

Eliyahu

"ruca" <ruuca@.iol.pt> wrote in message
news:e4d176wbEHA.3148@.TK2MSFTNGP10.phx.gbl...
> Hi
> How can I get a html control in my code?
> I have a html table that I want the width is defined in code at run time,
> i.e., I have this table and I have a datagrid. This datagrid have a
variable
> width because the number of columns depends of something that I have (that
> is not important for this). Now, what I want is that the html table have
> always the same width of my datagrid because of alignment of both.
> NOTE: I must have (and want) the datagrid width variable and not fixed
>
> --
> Programming ASP.NET with VB.NET
> Thank's (if you try to help me)
> Hope this help you (if I try to help you)
> ruca

Tuesday, March 13, 2012

Set Page Breaks When Printing

This is more of an HTML question...I guess.

I am populating an aspx page that has a single label control. The label control is populated with HTML code that is stored in a database. This HTML is code that creates a printable version of an application that customers are filling out. The form does not always fit on a single page.

How can I set markers in the HTML that indicate where one page ends and the next begins?

look at CSS... I belive the tag is "page-break: after;" and "page-break: before;"


Ha! Thank you!

I found an online resource that was helpful thanks to your suggestion:http://www.javascriptkit.com/dhtmltutors/pagebreak.shtml

Set Select Control's Value from Querystring

This is probably very easy.
How do I set an HTML select control's value from the querystring?
This is what I have...but, only the select control's value doesn't get
set.
CustomerSelect.Value = Request.QueryString("cus")
StartDate.Text = Request.QueryString("Sdate")
This works...
StartDate.Text = Request.QueryString("cus")
Thanks,
j.t.wIf you just want a dropdown, consider the server controls rather than HTML
controls and then set selected value to the key value you wish. I can look
at the HTML control and probably guide there, but the server controls are
fairly straightforward.
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA
****************************************
*********
| Think outside the box!
|
****************************************
*********
"j.t.w" <j.t.w@.juno.com> wrote in message
news:a9a2e312-6182-45b3-83b5-5298b955a785@.q78g2000hsh.googlegroups.com...
> This is probably very easy.
> How do I set an HTML select control's value from the querystring?
> This is what I have...but, only the select control's value doesn't get
> set.
> CustomerSelect.Value = Request.QueryString("cus")
> StartDate.Text = Request.QueryString("Sdate")
> This works...
> StartDate.Text = Request.QueryString("cus")
> Thanks,
> j.t.w
Try setting the SelectedValue or SelectedText properties.
"j.t.w" <j.t.w@.juno.com> wrote in message
news:a9a2e312-6182-45b3-83b5-5298b955a785@.q78g2000hsh.googlegroups.com...
> This is probably very easy.
> How do I set an HTML select control's value from the querystring?
> This is what I have...but, only the select control's value doesn't get
> set.
> CustomerSelect.Value = Request.QueryString("cus")
> StartDate.Text = Request.QueryString("Sdate")
> This works...
> StartDate.Text = Request.QueryString("cus")
> Thanks,
> j.t.w
>