|
First, a definition of context. I'm working with user controls, which utilize the .ascx markup with the codebehind pointing to the .cs, basically the same model as a page. This is not the same as custom server controls, which are precompiled and generate the html output by hand. I have a significant number of user controls which display grids and other non trivial forms of output.
What I'm looking to do is build snippets of script code that people can copy & paste into their own web site, thus displaying the data that I feed them through the script. An example of this might be:
<script src="http://www.website.com/ShowList.aspx"></script>
the result of which would be displaying the grid view on the site who pasted this script into their page. This is a fairly common technique for javascript output. If I wanted to print "Hello, World!" on your web page, in the Page_Load of ShowList.aspx I could do something like this:
<br />
Response.Write("document.write('Hello World!');");<br />
By pasting the above script onto your page, Hello, World! magically appears. So far, so good. If I wanted to output something more complex, like a table, I could update the output to instead call document.getElementById() of some predefined div and then set the element's innerHTML to the HTML of the table, etc. Then the table would appear on your page, as if by magic. Again, no problem to do.
Now we get to the fun part. I don't want to reinvent the wheel and code the logic of dozens of controls all over again, using this model, so that I can use them as output in the aforementioned scripting scenario. What I really want to do is effectively hook into the output of the user control and redirect that output for use by the script. Here's a pseudo code idea of what I mean:
- Page_Load of ShowList.aspx spits out opening javascript, i.e. document.getElementById() our div
- UserControlOne.ascx outputs a grid control, we redirect the final html output of this grid to a routine in ShowList
- This routine takes the html and assigns it to the innerHTML of the element we found in step 1
- We now bask in the glory of our grid being automagically output to the user of the one line of script code
As you can see, where the rubber meets the road is hooking the html output of our user control so that we can redirect it to the output stream being formatted as javascript, and that's the part I'm having difficulty with. In the old C++ / MFC days, it was an ongoing business of finding out where you needed to hook something, hacking your way into it and redirecting it to where you wanted it to go. The fact that you had the full MFC code that you could step through in your debugger helped immensely, of course.
Unfortunatly, my knowledge of the ASP.NET architecture isn't yet that deep, and so I'm struggling trying to figure out how to hook the output of a user control and point it where I want it to go, i.e. the example above.
Apologies for the long explanation, but I asked this question last week and got little response because I really didn't ask the question very well. Hopefully this will give the knowledgable among you sufficient information about what I'm trying to accomplish that you can point me in the right direction.
And of course, any help would be most gratefully accepted!
|
|
|
|
|
Good Afternoon All
Am new to ASP.NET 2.0 or any other ASP.NET versions, i have a Book and am working on it. Please dont eat me for the following Basic Question. i have a Blank Pade, it has appeared as Default.ASPX, so i have Added a Pic in the PAge and wrote some text that says UnderConstructions. So when i run this Pic it does not Show, i have added a Calender server control and it does not show when the page is loaded.This mage i have added, i have done it using the image server control. and it does not show.
1)what should i keep in mind about server controls when i add them to my page?
2)What is the Difference betwwen them and other Controls(Still comming Chapter in my Book)
please give me more Advice
Thanks
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
add runat="server" to your components
|
|
|
|
|
Hi man Thanks for your reply,
I thought VS do it for you, i have checked the Sorce that VS generate when dropping the control into the form and it look like this
<asp:Calendar ID="Calendar1" runat="server" BackColor="#FFFFCC" BorderColor="#FFCC66"
BorderWidth="1px" DayNameFormat="Shortest" Font-Names="Verdana" Font-Size="8pt"
ForeColor="#663399" Height="200px" ShowGridLines="True" Width="220px" OnSelectionChanged="Calendar1_SelectionChanged" VisibleDate="2008-04-16">
<SelectedDayStyle BackColor="#CCCCFF" Font-Bold="True" />
<TodayDayStyle BackColor="#FFCC66" ForeColor="White" />
<SelectorStyle BackColor="#FFCC66" />
<OtherMonthDayStyle ForeColor="#CC9966" />
<NextPrevStyle Font-Size="9pt" ForeColor="#FFFFCC" />
<DayHeaderStyle BackColor="#FFCC66" Font-Bold="True" Height="1px" />
<TitleStyle BackColor="#990000" Font-Bold="True" Font-Size="9pt" ForeColor="#FFFFCC" />
</asp:Calendar>
</p>
And it the like is there, but still it does not do anything
Thanks
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
can you show the ASPX-code form the asp:Image-component?
|
|
|
|
|
no i cant, in the Flowing page, as i said , there is Calender Control, a Photo and some text that says Under Construction. here is the Page address.
http://www.tiyaneproperties.co.za/index.aspx[^]
thanks
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
the url of your image is
http://www.tiyaneproperties.co.za/httpdocs/images/tiyane2.jpg[^]
It results in a 404. So the image is not there on your webserver. That is why it is not showing.
your page code is:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="index.aspx.cs" Inherits="httpdocs_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<br />
<br />
<asp:Image ID="Image1" runat="server" Height="184px" ImageUrl="~/httpdocs/images/tiyane2.jpg"
Width="520px" /><br />
<br />
<span style="font-size: 24pt; font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman';
mso-ansi-language: EN-GB; mso-fareast-language: EN-GB; mso-bidi-language: AR-SA">
<strong>
Under Construction</strong></span></div>
</form>
</body>
</html>
It does not say anything about your Calendar Control.
Have you published your latest codings on the webserver?
|
|
|
|
|
Thansk man for your Patience
let me explain this Situation. Am using a Domain bought from www.webonline.biz, it look that they use Apache webserver for hosting the Domains(Am not sure), but i have another Example pages that am doing and Pics come out. check this one http://www.tiyaneproperties.co.za/Wrox%20United/History.aspx[^]
And the pic is well displayed, but the pic am trying to Display in the other site, its not displaying, the Pic is available in the image Folder, its not like am coding it my self, i just Browse to it in the Property wondows of VS. so am not sure what wrong there
thanks
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Well,
if (image in the folder && image is located via VS)
Are there any blocking rights on the folder of the webserver?
|
|
|
|
|
hi
My Permissions are Fine, Do you think my web server does not support ASP.NET 2.0, if my service provider is using Apache, am not sure but i see this www.tiyaneproperties.co.za. i Supposed that might be the Problem, if its like this , will i get a chagen to develop for ASP.NET 2.0?
Thanks
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
2 - a server control emits HTML based on code that runs on the server. Normal HTML controls are spit out verbatim. If you add any attributes to a server control that the server does not recognise, it passes them through verbatim to the client, no other code you enter on a server control makes it to the client, it just tells the framework what code to generate.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
what namespace is used for get server date and time
|
|
|
|
|
FOR GOD SAKE STOP USING QUESTION AS YOUR BLOODY THREAD TITLE, THEY ARE ALL QUESTIONS!!
|
|
|
|
|
J4amieC wrote: THEY ARE ALL QUESTIONS!!
I'm pretty sure I have seen a few that were not.
led mike
|
|
|
|
|
Its System.DateTime.Now
Rocky
Success is a ladder which you can't climb with your hands in your pockets.
|
|
|
|
|
System.DateTime
Ashish Sehajpal
|
|
|
|
|
using System;
Console.WriteLine(DateTime.Now.ToString());
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
|
|
|
|
|
Hi all,
i have a table that column named:
price_id
min
max
now i want that my dropdwonlist shows this format for my price range
min-max(for example 10-20 )
how i can use this format in DataTextField, that it be bound to min and max and show "-" between them?
thank you,
Hoda
|
|
|
|
|
use query like this:
SELECT min, (min + ' -- ' + max) AS fieldname
|
|
|
|
|
SELECT price_id,(cast(min as varchar(10)) + ' -- ' + cast(max as varchar(10)) AS fieldname from tablename
Ashish Sehajpal
|
|
|
|
|
I start a process pdftk.exe to merger PDF files in ASP.NET web application. It woks fine in a single web server environment but doesn’t work in a web farm (2 clustered web servers) environment (got ExitCode = 1). Anyone have any ideas?
|
|
|
|
|
Does it really matter whether the server is in a cluster? The individual web server execution permissions should be the culprit to look into. Isn't it?
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
|
|
|
|
|
Hello
I m Working on gridview.how can i add new row in gridview using ajax toolkit
i had developed it till now like that
i want that on page refresh whatever in the grid till is kept
can anyone help me..
thanks
====aspx page======
]]>
<title>Untitled Page
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (PreviousPage == null)
{
if ("" != (string)Session["AddRow"])
{
btnAddRow();
btnAddRow();
}
else
{
btnDisRow();
}
}
}
else
{
Session["AddRow"] = "Yes";
}
if ("Yes" == (string)Session["AddRow"])
{
btnAddRow();
Session["AddRow"] = "";
}
}
<asp:scriptmanager id="ScriptManager1" runat="server">
<asp:updatepanel id="UpdatePanel1" runat="server">
<contenttemplate>
<asp:gridview id="grdnew" runat="server" enableviewstate="false" style="z-index: 100; <br mode=" hold=" /">left: 53px; position: absolute;top: 81px" CellPadding="4" ForeColor="#333333"
GridLines="None" AutoGenerateColumns="false">
<footerstyle backcolor="#990000" font-bold="True" forecolor="White">
<rowstyle backcolor="#FFFBD6" forecolor="#333333">
<selectedrowstyle backcolor="#FFCC66" font-bold="True" forecolor="Navy">
<pagerstyle backcolor="#FFCC66" forecolor="#333333" horizontalalign="Center">
<headerstyle backcolor="#990000" font-bold="True" forecolor="White">
<alternatingrowstyle backcolor="White">
<columns>
<asp:templatefield>
<headertemplate>
<asp:label id="lblimg" runat="server" text=" ">
<asp:label id="Label1" runat="server" text="Name">
<asp:label id="Label2" runat="server" text="ContactNo">
<asp:label id="Label3" runat="server" text="Email">
<asp:label id="Label4" runat="server" text="Designation">
<itemtemplate>
<asp:imagebutton id="btnimgadd" runat="server">
ImageUrl="~/add.gif" ToolTip="Add Row" OnClick="Button1_Click" />
<asp:textbox id="TextBox1" runat="server">
EnableViewState="true" Text='<%# Eval("Name")%>' Width ="100px" />
<asp:textbox id="TextBox2" runat="server">
EnableViewState="true" Text='<%# Eval("contactNo")%>' Width ="100px" />
<asp:textbox id="TextBox3" runat="server">
EnableViewState="true" Text='<%# Eval("email")%>' Width ="100px"/>
<asp:textbox id="TextBox4" runat="server">
EnableViewState="true" Text='<%# Eval("designation")%>' Width ="100px" />
<triggers> <asp:asyncpostbacktrigger controlid="bUpdate1" eventname="Click">
<asp:button id="bUpdate1" runat="server" text="Click Here" onclick="bUpdate1_Click">
<asp:updateprogress id="UpdateProgress1" runat="server" associatedupdatepanelid="UpdatePanel1">
<progresstemplate>
Getting Data From Server.....
=======cs file=======
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using MySql.Data.MySqlClient;
public partial class Default2 : System.Web.UI.Page
{
DataSet ds;
MySqlConnection mcon;
MySqlCommand mcmd;
MySqlDataAdapter mda;
DataTable dt;
DataRow dr;
protected void btnAddRow()
{
dt = CreateDataTable();
grdnew.DataSource = dt;
grdnew.DataBind();
}
protected void btnDisRow()
{
dt = (DataTable)ViewState["DataTable"];
grdnew.DataSource = dt;
grdnew.DataBind();
}
protected DataTable CreateDataTable()
{
DataTable dtvalues = (DataTable)ViewState["DataTable"];
if (dtvalues == null)
{
dtvalues = new DataTable();
dtvalues.Columns.Add(new DataColumn("", typeof(string)));
dtvalues.Columns.Add(new DataColumn("Name", typeof(string)));
dtvalues.Columns.Add(new DataColumn("contactNo", typeof(string)));
dtvalues.Columns.Add(new DataColumn("email", typeof(string)));
dtvalues.Columns.Add(new DataColumn("designation", typeof(string)));
ViewState["DataTable"] = dtvalues;
}
else
{
dr = dtvalues.NewRow();
dtvalues.Rows.Add(dr);
ViewState["DataTable"] = dtvalues;
}
return dtvalues;
}
protected void bUpdate1_Click(object sender, EventArgs e)
{
}
}
|
|
|
|
|
Ankit At Codeproject wrote: how can i add new row in gridview using ajax toolkit
ASP.NET render Gridview as HTML table. So I guess update panel can't update this. I am not sure
|
|
|
|
|
I have been able to save time with a better version GridViewEx from www.MyCustomControls.com...there is a lot of precise documentation there as well on how to do everything you need, plus it's super economical
|
|
|
|