Monday, March 26, 2012
This is for the nth time I am posting. Is there no one to help!
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!!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!!
sounds like you are not leveraging the page.postback property. page_load
gets called every time the page loads whether it is post back or not. the
onserverclicks will get loaded after page_load. sounds like you are loading
the datalist twice before doing a request.form on the data. you should only
build the datalist once. it will be in the viewstate on the postback, so no
need to reload it.
function page_load()
if page.ispostback then
'get checkbox values and labels or do nothing and rely on the
OnServerClick event
else
'load datalist
end if
end function
also if you want to use javascript onclick and asp.net's onserverclick do
this...
<input type="submit" id="btn" value="go" runat="server" onclick="return
validate();"
if you use <asp:button...>, the onclick event is looking for a public
function in the codebehind which default to private... not sure, but I have
to change that to public everytime.
again, without code samples, it is tough. I hope I helped a little bit.
~psb
"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!!
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
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
This is killing me... need to display custom HTML from remote site to a calling site
Ok, I hope someone has done this or can help me here as I'm having trouble finding what I need.
What I want to do is allow users to include a javascript file in their website that will go out and pull data from my site / db and display it on their website. What will happen is they pass over some specific information that indicates what they want returned and then I'll serve it to their website where it displays in a naturally embedded format and looks like it's part of their own content.
An example of what I want to do is the same as the following:
<div style="padding-left:10px; padding-right:10px;">
<asp:PlaceHolder ID="plcContent"runat="Server"><script language="javascript" src="http://pics.10026.com/?src=http://www.datafeedfile.com/dff_jsthrow.php?affid=1001&script=search_index&style=12"></script>
</asp:PlaceHolder>
</div>
What the above line does is display contents (full HTML) from data feed file onto a webpage (shopping content), but doesn't actually render the full HTML to the webpage (if you right-click and view source). I want to do the same thing where someone calls a .ASPX or .ASMX page / service and I return (or serve) the HTML content. So, a call to my app may look like:
<div style="padding-left:10px; padding-right:10px;">
<asp:PlaceHolder ID="plcContent"runat="Server"><script language="javascript" src="http://pics.10026.com/?src=http://www.mysite.com/contentsource.aspx?affid=1001&type=X"></script>
</asp:PlaceHolder>
</div>
The contentsource.aspx page will then return (or display) a listing of products from my website on the calling website.
Can that be done in ASP.NET 2.0? Any help much appreciated as I've been searching for a couple days (and many many hours of trial and error) with no luck. Thanks!
Hi,
Try to use IFRAME, see http://www.w3schools.com/tags/tag_iframe.asp
Add this to your page (and remove html from the ASPX that shouldn't be there, such as <body>, <head> etc.)
protected override void Render(HtmlTextWriter writer)
{
StringBuilder sb=new StringBuilder();
StringWriter sw =new StringWriter(sb);
HtmlTextWriter hw =new HtmlTextWriter(sw);
base.Render(hw);Response.Clear();
Response.ContentType ="text/javascript";string html =string.Format("window.document.write({0});",Enquote(sb.ToString()));
writer.Write(html);}
/// FUNCTION Enquote Public Domain 2002 JSON.org
/// @.author JSON.org
/// @.version 0.1
/// Ported to C# by Are Bjolseth, teleplan.no
public static string Enquote(string s)
{
if (s ==null || s.Length == 0)
{
return"\"\"";
}
char c;
int i;
int len = s.Length;
StringBuilder sb =new StringBuilder(len + 4);
string t;sb.Append('"');
for (i = 0; i < len; i += 1)
{
c = s[i];
if ((c =='\\') || (c =='"') || (c =='>'))
{
sb.Append('\\');
sb.Append(c);
}
else if (c =='\b')
sb.Append("\\b");
else if (c =='\t')
sb.Append("\\t");
else if (c =='\n')
sb.Append("\\n");
else if (c =='\f')
sb.Append("\\f");
else if (c =='\r')
sb.Append("\\r");
else
{
if (c <' ')
{
//t = "000" + Integer.toHexString(c);
string tmp =new string(c, 1);
t ="000" +int.Parse(tmp, System.Globalization.NumberStyles.HexNumber);
sb.Append("\\u" + t.Substring(t.Length - 4));
}
else
{
sb.Append(c);
}
}
}
sb.Append('"');
return sb.ToString();
}
Thanks, but that doesn't quit work for what I want. I just want users to be able to do it via a javascript call like in the example I provided. IFrames are kinda ugly, clunky, and not really something I would want to ask users to drop into their sites. I appreciate the reply though!
guntem,
That's exactly what I needed! Very very much appreciated as you've saved me much time and frustration.
David
Thursday, March 22, 2012
Thread aborted when doing HttpContext.Current.Response.End
I have written a function to export the datagrid data to excel. In that
function I was calling HttpContext.Current.Response.End() at the end. If I a
m
doing this, I am getting an exception message "Thread was being aborted". If
I don't do this then it is exporting the whole data instead of just the
datagrid. I am not knowing what might be the problem. Please let me know if
you have any idea
Thnx,
Sridhar.That's just how Response.End() works, it throws a ThreadAbortExxception.
You can't doing anything wrong, but you may. You'll either need to handle
(catch/swallow/hide) the exception or change your page so only the grid
shows and there's no need to End the request.
Karl
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!
"Sridhar" <Sridhar@.discussions.microsoft.com> wrote in message
news:92D1C4A0-006D-4DB7-87D3-86E26C8D0FD9@.microsoft.com...
> Hi,
> I have written a function to export the datagrid data to excel. In that
> function I was calling HttpContext.Current.Response.End() at the end. If I
> am
> doing this, I am getting an exception message "Thread was being aborted".
> If
> I don't do this then it is exporting the whole data instead of just the
> datagrid. I am not knowing what might be the problem. Please let me know
> if
> you have any idea
> Thnx,
> Sridhar.
Thread aborted when doing HttpContext.Current.Response.End
I have written a function to export the datagrid data to excel. In that
function I was calling HttpContext.Current.Response.End() at the end. If I am
doing this, I am getting an exception message "Thread was being aborted". If
I don't do this then it is exporting the whole data instead of just the
datagrid. I am not knowing what might be the problem. Please let me know if
you have any idea
Thnx,
Sridhar.That's just how Response.End() works, it throws a ThreadAbortExxception.
You can't doing anything wrong, but you may. You'll either need to handle
(catch/swallow/hide) the exception or change your page so only the grid
shows and there's no need to End the request.
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!
"Sridhar" <Sridhar@.discussions.microsoft.com> wrote in message
news:92D1C4A0-006D-4DB7-87D3-86E26C8D0FD9@.microsoft.com...
> Hi,
> I have written a function to export the datagrid data to excel. In that
> function I was calling HttpContext.Current.Response.End() at the end. If I
> am
> doing this, I am getting an exception message "Thread was being aborted".
> If
> I don't do this then it is exporting the whole data instead of just the
> datagrid. I am not knowing what might be the problem. Please let me know
> if
> you have any idea
> Thnx,
> Sridhar.