|
Back in the old days of ASP, I could create a global page, reiterate thru a database and pass the records' value to variables that a simple <%=(var)%> and an include tag, on another page would catch.
But for more flexibility, I created a Client Class, passed the db record values to the client class properties to a .vb page, and want to use those values, sometimes multiple times on the same page (hence no user controls are no good). I know I could insert an include tag on the receiving page, and declare a public variable on the .vb page that inherits the class & reiterates thru the db, but Pubic variables worry me.
Does anyone have any suggestions on how to use class objects on other .aspx web pages, without using controls, that basically accomplish the same thing as an include tag with a <%=(var)%> script?
|
|
|
|
|
You can use session variable.
/***********************/
Parwej Ahamad
g.parwez@gmail.com
/***********************/
|
|
|
|
|
Won't there be a performace issue if i use too many session variables?
|
|
|
|
|
Yes, may be if you will use very large object. But you can handle it in different way.
Please find the below link.
vishaljoshi.blogspot.com/2003/10/session-variables-operational.html
/***********************/
Parwej Ahamad
g.parwez@gmail.com
/***********************/
|
|
|
|
|
What would be a second alternative if I didn't want to use session objects? It seems the pages that truly preclude me from using the ole method of embedding redundant data are pages that include forms.
Let me be specific: Let's say I have content that I want to use and reuse for different websites. The variables in the content from each are company name, phone number, address, and other unique data. Ideally, I'd like to store the reusable content into a sql table with the unique variable data script embedded with in (as example in ASP 1.0: "<td><%=(CompanyName")%> has been in business for
<%=(YearsinBiz")%>. Our owners work hard for our customers, you can contact them, their names are <%=("Name1")%> .......</td>" .....
As you can see, their could be a myriad of data for embedding and I do not think session objects are the best choice.
Again, I have captured all the data into my Client Class Object. I now need to replicate that information, sometimes, more than once on the same page, and a simple <%=("var")%> tag causes havoc on the pages that have forms. And, since I try to have a quick contact form on the side of each page, I have a problem.
I hope I have better explained my delima and maybe you have a solution to share. Thanks.
|
|
|
|
|
"<td><%=(CompanyName")%> has been in business for
<%=(YearsinBiz")%>. Our owners work hard for our customers, you can contact them, their names are <%=("Name1")%> .......</td>" .....
First: Above string, You need to manipulate in code bihind file with the client object information.
Note: you can use String Builder for large string manipulation.
Second: client object hold into the session variable.
/***********************/
Parwej Ahamad
g.parwez@gmail.com
/***********************/
|
|
|
|
|
Working on first web dev site in VWD 08. I can get the FormView control to sync w/ GridView control using the code below and ONLY for the first 10 records. When I click the pager link to page 2, I can't get the next batch of records to display in FormView, it stops at 10.
What Gives?
Question:
What code or property setting will make this function work?
Current Code:
Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged
FormView1.PageIndex = GridView1.SelectedIndex
End Sub
|
|
|
|
|
Ah - you cross posted. Just post in the ASP.NET forum if the question is ASP.NET.
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|
Is it possible to to read the ftp file without downloading the files to the local drive ?
Thanks
|
|
|
|
|
You could start FTPing it and stop when you have the bit you want...
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|
Use the WebClient.DownloadData method to get the file from ftp as a byte array.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Oh - I see what he meant now...
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|
Do you have some sample codes,
My goal is connect to the ftp site read the content of the text file remotely and i would like to read it and send it to memory, made some change to the text file then ftp the file to another ftp server
at the moment i downloaded the file to local and made change to the file and then ftp to another server, then delete the local copy
if i can read of the server and stream it to memory that would increase the performance greatly.
any help would greatly appreciated
|
|
|
|
|
|
i want to develop web messenger
i read
http://www.codeproject.com/KB/HTML/Yahoo.aspx
but i have some problems
1)
when i click on the link after setting every thing yahoo chat interface appears which i dont want i have a text box and i want to send and recieve messages written in it
2)
if i add links for all my yahoo contacts it works i-e i can send text from yahoo chat interface but i dont want to hard code contacts all contacts should come automatically from my yahoo messenger contact list
Please help me
modified on Tuesday, February 19, 2008 9:11 PM
<div class="ForumMod">modified on Tuesday, February 19, 2008 9:12 PM</div>
|
|
|
|
|
<xsl:element name="li">
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="concat('m','.aspx')"/>
</xsl:attribute>
<xsl:value-of select="aspdnsf:GetMLValue(Name)"/>
</xsl:element>
</xsl:element>
this code creates a list of links but i want to create dropdown how can i do this
modified on Tuesday, February 19, 2008 6:09 PM
|
|
|
|
|
I suggest reading a book on XSLT instead of blindly copying and pasting code from the web.
a is an anchor element, a link. Replace the element with a list item and wrap them in an element to create the list, and you're done.
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|
Well, having fixed my problem with caching (or so I thought) by deleting an old website and re-publishing it, I now have a new set of fun problems. I suspect I've caused them whilst trying to force the new version of a page through. A different page is now misbehaving.
I have a button which when clicked, changes the datasource for a gridview based on it's own text, then changes it's own text (so that next time it is clicked it will perform the other action, and change it's text back again). However now, although the first click works ok* when clicked again it fires as though it has the same text.
protected void btn_switchallorown_Click(object sender, EventArgs e)
{
switch (btn_switchallorown.Text)
{
case "Show queued requests for ALL departments":
btn_switchallorown.Text = btn_switchallorown.Text.Replace("ALL departments", "YOUR department");
break;
case "Show queued requests for YOUR department":
btn_switchallorown.Text = btn_switchallorown.Text.Replace("YOUR department", "ALL departments");
break;
default:
break;
}
gvw_Queued_Requests.DataBind();
gvw_totals.DataBind();
}
Can anyone suggest what I may have broken? This all worked quite happily before? I have tried re-enabling the viewstate but no joy...
* except that a tree-view used for navigation collapses to it's root node (never did before).
|
|
|
|
|
Have you tried setting a breakpoint to see what's happening ? This code does n't change the datasource at all, it just changes the button text and rebinds to the same sources they have.
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|
Yes - I set a breakpoint at the beginning of this event handler - I have removed the sql changes for clarity brevity
The issue I have is that the first time the event fires, the text displayed is changed (as expected). The second time the button is clicked, the event fires but the button text (which I am using in the switch) remains the same as the first click, triggering the same case again. I think the issue is something to do with the postback - the navigation tree collapses on postback.
My Page_Load event is:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (User.Identity.Name != "")
{
if (Session["userName"] == null)
Session["userName"] = Requestor.user_name(User.Identity.Name, 3);
if (Session["deptname"] == null)
Session["deptName"] = Requestor.dept_name(Session["userName"].ToString());
string deptname = Session["deptName"].ToString();
if (!Requestor.Valid_User(User.Identity.Name))
Response.Redirect("dberror.htm");
else
{
Navigator.FillTreeMenu(NavTree, deptname);
}
lbl_User.Text = Requestor.user_name(User.Identity.Name, 1);
}
else
Response.Redirect("usernameerror.aspx");
SQLQueued.SelectCommandType = SqlDataSourceCommandType.StoredProcedure;
SQLQueued.SelectCommand = "cp_Get_Queued_Info";
gvw_totals.DataBind();
}
}
In addition to the button misbehaviour, lbl_User.Text gets blanked. I think it has to be a viewstate/caching/compilation thing..?
|
|
|
|
|
OK - "problem" solved. It was a viewstate issue.
Some idiot had discovered that disabling the viewstate on a slow-loading page improved performance. And decided to do the same thing on every page. Including the Master Pages.
Which is why enabling/disabling the viewstate on the content page did pretty much zip.
My apologies for wasting your valuable time.
Of course had I been documenting my modifications as I went along, I might have twigged a little quicker...
|
|
|
|
|
How would i specify a colour for a button
e.g.
btbutton.color = color #ffffff
i need to set it to a custom # color
thanks
|
|
|
|
|
Use the FromArgb method to create a color from color components:
btbutton.color = Color.FromArgb(255, 255, 255);
or
btbutton.color = Color.FromArgb(0xff, 0xff, 0xff);
If you want to specify a single hexademial value, you have to specify the opacity also:
btbutton.color = Color.FromArgb((int)0xffffffff);
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
<asp:TemplateField > <ItemTemplate>
<%-- <asp:LinkButton ID="lnkReplyHeading" runat="server" ><%# DataBinder.Eval(Container.DataItem,"u.username") %></asp:LinkButton>--%>
<asp:LinkButton id="lnkusername" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"u.username")%>' commandname="ss" > </asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
System.Data.DataRowView' does not contain a property with the name 'u'.
modified on Tuesday, February 19, 2008 8:43 AM
|
|
|
|
|
Hi Ritu!
Can you plz explain the problem in detail. I can't understand what is the problem.
|
|
|
|