Showing posts with label javascript. Show all posts
Showing posts with label javascript. Show all posts

Monday, March 26, 2012

This is for the nth time I am posting. Is there no one to help!

This is how the presentation code look like. If I use
runat = server, ie; when I try to use onserverclick on the
button the javascript doesn't work . The displayanswers
method in the form returns a string of html text,basically
a table with radiobuttons or checkboxes aligned in it.

<form id="frmQuestion" method="post"
<ASP:DataList id="Questions" ShowHeader="false"
ShowFooter="false" runat="server" >
<ItemTemplate>
<TABLE ALIGN="left" >
<td
<asp:Label runat="server" Text='<%# DataBinder.Eval
(Container.DataItem, "MainQuestion_ID")%> '
ID="QuestionID" NAME="QuestionID">
</asp:Label
</td
<td
<asp:Label runat="server" Text='<%# DataBinder.Eval
(Container.DataItem, "MainQuestion_Txt")%>'
ID="QuestionTxt" NAME="QuestionTxt">
</asp:Label
</td
<td
<%# DisplayAnswers(DataBinder.Eval
(Container.DataItem, "MainQuestion_ID"),DataBinder.Eval
(Container.DataItem, "QuestionTypeID")) %
</td>
</tr></TABLE>
</ItemTemplate>
</ASP:DataList
<table align=right >
<tr><td
<a id=btnForward href="http://links.10026.com/?link=#"
onMouseOut="bforward.src='images/bforward.gif';"
onMouseOver="bforward.src='images/bforward_f2.gif';"
runat=server onclick="return validate();"><IMG
SRC="images/bforward.gif" ALT="" NAME="bforward"
ID="bforward" WIDTH="78" HEIGHT="24" BORDER="0"></A
</td></tr></table
I would like to retrieve the question id and the answer
(user-input) at the same time on click of the button. The
questionaire is paginated and this is the only form i am
using.

The code behind looks somewhat this way:

Sub Page_Load(ByVal Sender As Object, ByVal E As
EventArgs)

Dim oDt As DataTable
Dim oQuestion As Question ('This is the class
in my business layer)
oQuestion = New Question

Questions.DataSource = New DataView(oDt)
Questions.DataBind()

End Sub

What is the best way to handle Questionaire(online test)
projects . Can I display questions and answers at the same
time and how do I get questionid's and user-input to
insert into the database. There can be subquestions

From: "Corey Wineman" <cwineman@dotnet.itags.org.no-spam-adelphia.net
Maybe you could post some code. Its hard to tell what your
problem is from
you message which you have posted several times.

"ani" <anonymous@dotnet.itags.org.discussions.microsoft.com> wrote in
message
news:01b601c3a3ce$cbdc78c0$a401280a@dotnet.itags.org.phx.gbl...
> I have a datalist control in my aspx page(this is
> paginated and everytime submits to itself). I am calling
a
> function within my datalist that returns a html control
> (radio button ) in the form of the string. I also have
asp
> server controls(labels) in the datalist. When the form is
> processed, I am retrieving the values of the radio
buttons
> through Request.form. To retrieve the values of the asp
> server controls , I am using FindControl method. But this
> is written in the Page_Load method, so it returns the
> values of the current page before the page gets
submitted.
> I want the values after the page gets submitted. How do I
> retrieve them.
> If I use onserverclick on my button (which is a html
> control with rollover capability <a href>) , the onclick
> doesn't work fine for validating the html controls. I
> don't have runat=server on my form tag when I have
onclick
> attribute on the button. I am new to asp.net. I am not
> able to use both onclick and onserverclick at the same
> time. Why is it so..
> Please help!!

..I am guessing that your problem is with the <a href="http://links.10026.com/?link=#"
portion of your code. The problem is that you have a
runat=server on this control. The OnClick for the <a>
will then submit to the server, not to the javascript on
the client side. If you take that out, you should be
fine.

If you want to do validation on the click of the link,
you will need to put a custom validator in there.

I hope this helps

>--Original Message--
>This is how the presentation code look like. If I use
>runat = server, ie; when I try to use onserverclick on
the
>button the javascript doesn't work . The displayanswers
>method in the form returns a string of html
text,basically
>a table with radiobuttons or checkboxes aligned in it.
><form id="frmQuestion" method="post" >
><ASP:DataList id="Questions" ShowHeader="false"
>ShowFooter="false" runat="server" >
><ItemTemplate>
><TABLE ALIGN="left" >
><td>
> <asp:Label runat="server" Text='<%# DataBinder.Eval
>(Container.DataItem, "MainQuestion_ID")%> '
>ID="QuestionID" NAME="QuestionID">
> </asp:Label>
></td>
><td>
> <asp:Label runat="server" Text='<%# DataBinder.Eval
>(Container.DataItem, "MainQuestion_Txt")%>'
>ID="QuestionTxt" NAME="QuestionTxt">
> </asp:Label>
></td>
><td >
><%# DisplayAnswers(DataBinder.Eval
>(Container.DataItem, "MainQuestion_ID"),DataBinder.Eval
>(Container.DataItem, "QuestionTypeID")) %>
></td>
></tr></TABLE>
></ItemTemplate>
></ASP:DataList>
><table align=right >
><tr><td>
> <a id=btnForward href="http://links.10026.com/?link=#"
>onMouseOut="bforward.src='images/bforward.gif';"
>onMouseOver="bforward.src='images/bforward_f2.gif';"
>runat=server onclick="return validate();"><IMG
>SRC="images/bforward.gif" ALT="" NAME="bforward"
>ID="bforward" WIDTH="78" HEIGHT="24" BORDER="0"></A>
></td></tr></table>
>
>I would like to retrieve the question id and the answer
>(user-input) at the same time on click of the button.
The
>questionaire is paginated and this is the only form i am
>using.
>The code behind looks somewhat this way:
> Sub Page_Load(ByVal Sender As Object, ByVal E As
>EventArgs)
>
> Dim oDt As DataTable
> Dim oQuestion As Question ('This is the
class
>in my business layer)
> oQuestion = New Question
> Questions.DataSource = New DataView(oDt)
> Questions.DataBind()
>
>End Sub
>
>What is the best way to handle Questionaire(online test)
>projects . Can I display questions and answers at the
same
>time and how do I get questionid's and user-input to
>insert into the database. There can be subquestions
>
>From: "Corey Wineman" <cwineman@.no-spam-adelphia.net>
>Maybe you could post some code. Its hard to tell what
your
>problem is from
>you message which you have posted several times.
>
>"ani" <anonymous@.discussions.microsoft.com> wrote in
>message
>news:01b601c3a3ce$cbdc78c0$a401280a@.phx.gbl...
>> I have a datalist control in my aspx page(this is
>> paginated and everytime submits to itself). I am
calling
>a
>> function within my datalist that returns a html control
>> (radio button ) in the form of the string. I also have
>asp
>> server controls(labels) in the datalist. When the form
is
>> processed, I am retrieving the values of the radio
>buttons
>> through Request.form. To retrieve the values of the asp
>> server controls , I am using FindControl method. But
this
>> is written in the Page_Load method, so it returns the
>> values of the current page before the page gets
>submitted.
>> I want the values after the page gets submitted. How
do I
>> retrieve them.
>> If I use onserverclick on my button (which is a html
>> control with rollover capability <a href>) , the
onclick
>> doesn't work fine for validating the html controls. I
>> don't have runat=server on my form tag when I have
>onclick
>> attribute on the button. I am new to asp.net. I am not
>> able to use both onclick and onserverclick at the same
>> time. Why is it so..
>>
>> Please help!!
>>
>..
>
>.

Saturday, March 24, 2012

This Object in Javascript Causes Error

All,

I'm developing an website using ASP .NET. I have developed a menu
structure based on JavaScript. This JavaScript file is called by an
UserControl to generate the menus.

It works fine for the WebPage that lies in the same folder. But when i
use the same control in another page (another directory) it's not
working property. It shows an error "Object Required".

The statement is as given below,

this.css= "/scripts/intranet.css"
Also I'm not able to access the document object from Javascript.

TIAI think the problem is with the following statement,

this.css=
bw.dom?document.getElementById(obj).style:bw.ie4?d ocument.all[obj].style:bw.ns4?eval(nest+"document.layers."
+obj):0;

This statement set css value based on the Browser type. Is there any
problem in declaration?

This Object in Javascript Causes Error

All,
I'm developing an website using ASP .NET. I have developed a menu
structure based on JavaScript. This JavaScript file is called by an
UserControl to generate the menus.
It works fine for the WebPage that lies in the same folder. But when i
use the same control in another page (another directory) it's not
working property. It shows an error "Object Required".
The statement is as given below,
this.css= "/scripts/intranet.css"
Also I'm not able to access the document object from Javascript.
TIAI think the problem is with the following statement,
this.css=
bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?e
val(nest+"document.layers."
+obj):0;
This statement set css value based on the Browser type. Is there any
problem in declaration?

This works on my locahost, but not on a remote server?

Hello. This problem is perplexing me.

I have a asp:button which runs a javascript function when it is clicked. It
returns a true or false depending if a postback is needed. This works great
when I run it on my development pc. But, when I run it from another
computer, it ALWAYS does a postback, even if it returns false. I have no
ideas why??

The plot thickens... I don't know if this really matters or not, but this
button is in a datagrid.

Can anyone explain to me why the javascript function posts back??? The
code is posted below.

Thank you in advance!

SteveS

******ASPX CODE************

<asp:Datagirid.....>
..
<asp:TemplateColumn HeaderText="Deny" ItemStyle-HorizontalAlign=Center
HeaderStyle-HorizontalAlign=Center>
<ItemTemplate>
<asp:Button text="Deny" ID="btnDeny" Runat="server"
CommandName="btnDeny"></asp:Button>
</ItemTemplate>
</asp:TemplateColumn>
..
</asp:Datagrid
<script lang=javascript>
function OpenDenyWindow(changeId, btn) {
var ret = false
retVal=window.showModalDialog('DenialEmailForm.asp x?id=' +
changeId+'&mem='+document.Form1.hdnMemId.value,'', '');
alert ("retval = " + retVal)
if (retVal == "Successful") {
//return true
ret = true
}
else {
//return false
ret = false
}
alert(ret);
// *** even if this function returns a FALSE, the form is still posted
when I am not running the web page from my local host.
return ret;
}

**** CODE BEHIND****

Private Sub grdList_ItemCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles grdList.ItemCreated
'ADD THE JAVASCRIPT TO TO THE BUTTON
Dim ctrlDeny As Button = CType(e.Item.FindControl("btnDeny"),
Button)
If Not IsNothing(ctrlDeny) Then
Dim grid As DataGrid = CType(sender, DataGrid)
ctrlDeny.Attributes.Add("onclick", "return OpenDenyWindow("
& grid.DataKeys(e.Item.ItemIndex).ToString & ", this); return false;")
End If
End SubWhat is the configuration of the browser on the other PC? Maybe it has
disabled javascript?

"SteveS" <ssinger@.trendmls.com> wrote in message
news:uZ4IRSWIEHA.2128@.TK2MSFTNGP11.phx.gbl...
> Hello. This problem is perplexing me.
> I have a asp:button which runs a javascript function when it is clicked.
It
> returns a true or false depending if a postback is needed. This works
great
> when I run it on my development pc. But, when I run it from another
> computer, it ALWAYS does a postback, even if it returns false. I have no
> ideas why??
> The plot thickens... I don't know if this really matters or not, but this
> button is in a datagrid.
> Can anyone explain to me why the javascript function posts back??? The
> code is posted below.
> Thank you in advance!
> SteveS
>
> ******ASPX CODE************
> <asp:Datagirid.....>
> .
> <asp:TemplateColumn HeaderText="Deny" ItemStyle-HorizontalAlign=Center
> HeaderStyle-HorizontalAlign=Center>
> <ItemTemplate>
> <asp:Button text="Deny" ID="btnDeny" Runat="server"
> CommandName="btnDeny"></asp:Button>
> </ItemTemplate>
> </asp:TemplateColumn>
> .
> </asp:Datagrid>
> <script lang=javascript>
> function OpenDenyWindow(changeId, btn) {
> var ret = false
> retVal=window.showModalDialog('DenialEmailForm.asp x?id=' +
> changeId+'&mem='+document.Form1.hdnMemId.value,'', '');
> alert ("retval = " + retVal)
> if (retVal == "Successful") {
> //return true
> ret = true
> }
> else {
> //return false
> ret = false
> }
> alert(ret);
> // *** even if this function returns a FALSE, the form is still
posted
> when I am not running the web page from my local host.
> return ret;
> }
>
> **** CODE BEHIND****
> Private Sub grdList_ItemCreated(ByVal sender As Object, ByVal e As
> System.Web.UI.WebControls.DataGridItemEventArgs) Handles
grdList.ItemCreated
> 'ADD THE JAVASCRIPT TO TO THE BUTTON
> Dim ctrlDeny As Button = CType(e.Item.FindControl("btnDeny"),
> Button)
> If Not IsNothing(ctrlDeny) Then
> Dim grid As DataGrid = CType(sender, DataGrid)
> ctrlDeny.Attributes.Add("onclick", "return
OpenDenyWindow("
> & grid.DataKeys(e.Item.ItemIndex).ToString & ", this); return false;")
> End If
> End Sub
>
>
>

This works on my locahost, but not on a remote server?

Hello. This problem is perplexing me.
I have a asp:button which runs a javascript function when it is clicked. It
returns a true or false depending if a postback is needed. This works great
when I run it on my development pc. But, when I run it from another
computer, it ALWAYS does a postback, even if it returns false. I have no
ideas why'
The plot thickens... I don't know if this really matters or not, but this
button is in a datagrid.
Can anyone explain to me why the javascript function posts back'? The
code is posted below.
Thank you in advance!
SteveS
******ASPX CODE************
<asp:Datagirid.....>
.
<asp:TemplateColumn HeaderText="Deny" ItemStyle-HorizontalAlign=Center
HeaderStyle-HorizontalAlign=Center>
<ItemTemplate>
<asp:Button text="Deny" ID="btnDeny" Runat="server"
CommandName="btnDeny"></asp:Button>
</ItemTemplate>
</asp:TemplateColumn>
.
</asp:Datagrid>
<script lang=javascript>
function OpenDenyWindow(changeId, btn) {
var ret = false
retVal=window.showModalDialog('DenialEmailForm.aspx?id=' +
changeId+'&mem='+document.Form1.hdnMemId.value,'', '');
alert ("retval = " + retVal)
if (retVal == "Successful") {
//return true
ret = true
}
else {
//return false
ret = false
}
alert(ret);
// *** even if this function returns a FALSE, the form is still posted
when I am not running the web page from my local host.
return ret;
}
**** CODE BEHIND****
Private Sub grdList_ItemCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles grdList.ItemCreated
'ADD THE JAVASCRIPT TO TO THE BUTTON
Dim ctrlDeny As Button = CType(e.Item.FindControl("btnDeny"),
Button)
If Not IsNothing(ctrlDeny) Then
Dim grid As DataGrid = CType(sender, DataGrid)
ctrlDeny.Attributes.Add("onclick", "return OpenDenyWindow("
& grid.DataKeys(e.Item.ItemIndex).ToString & ", this); return false;")
End If
End SubWhat is the configuration of the browser on the other PC? Maybe it has
disabled javascript?
"SteveS" <ssinger@.trendmls.com> wrote in message
news:uZ4IRSWIEHA.2128@.TK2MSFTNGP11.phx.gbl...
> Hello. This problem is perplexing me.
> I have a asp:button which runs a javascript function when it is clicked.
It
> returns a true or false depending if a postback is needed. This works
great
> when I run it on my development pc. But, when I run it from another
> computer, it ALWAYS does a postback, even if it returns false. I have no
> ideas why'
> The plot thickens... I don't know if this really matters or not, but this
> button is in a datagrid.
> Can anyone explain to me why the javascript function posts back'? The
> code is posted below.
> Thank you in advance!
> SteveS
>
> ******ASPX CODE************
> <asp:Datagirid.....>
> .
> <asp:TemplateColumn HeaderText="Deny" ItemStyle-HorizontalAlign=Center
> HeaderStyle-HorizontalAlign=Center>
> <ItemTemplate>
> <asp:Button text="Deny" ID="btnDeny" Runat="server"
> CommandName="btnDeny"></asp:Button>
> </ItemTemplate>
> </asp:TemplateColumn>
> .
> </asp:Datagrid>
> <script lang=javascript>
> function OpenDenyWindow(changeId, btn) {
> var ret = false
> retVal=window.showModalDialog('DenialEmailForm.aspx?id=' +
> changeId+'&mem='+document.Form1.hdnMemId.value,'', '');
> alert ("retval = " + retVal)
> if (retVal == "Successful") {
> //return true
> ret = true
> }
> else {
> //return false
> ret = false
> }
> alert(ret);
> // *** even if this function returns a FALSE, the form is still
posted
> when I am not running the web page from my local host.
> return ret;
> }
>
> **** CODE BEHIND****
> Private Sub grdList_ItemCreated(ByVal sender As Object, ByVal e As
> System.Web.UI.WebControls.DataGridItemEventArgs) Handles
grdList.ItemCreated
> 'ADD THE JAVASCRIPT TO TO THE BUTTON
> Dim ctrlDeny As Button = CType(e.Item.FindControl("btnDeny"),
> Button)
> If Not IsNothing(ctrlDeny) Then
> Dim grid As DataGrid = CType(sender, DataGrid)
> ctrlDeny.Attributes.Add("onclick", "return
OpenDenyWindow("
> & grid.DataKeys(e.Item.ItemIndex).ToString & ", this); return false;")
> End If
> End Sub
>
>
>
>