|
Based on the code above, you have to click the button twice in order for the session var to show in the textbox.
this is because the execution goes in this order:
Page Load
--You click Button
Page Load
Button Click
|
|
|
|
|
Yes that was it.
I ended up using the prerender event.
Thanks
|
|
|
|
|
Try putting the following line in Web.config under the System.Web:
"sessionState mode="InProc" timeout="30" cookieless="false" /sessionState"
Lemme know if it worked !
|
|
|
|
|
I built a asp.net site solved all the debugger errors and tested it thoroughly, however when I published the webpages I get this compiler error message:
A name was started with an invalid character. Error processing resource 'file:///C:/Users/Matthew/Documents/Visual Studio 2...
<%@ page language="VB" autoeventwireup="false" inherits="special, App_Web_7wnhu2hb" %>
-^
Note: the code is stored in a filename.aspx.vb file in the solution and not embedded into the the filename.aspx like
<source type="text/vbscript"> code here </source>
This is my first time posting so if you need more info or the code for the website please ask and I will show it. I'm new to web programming, so whatever help you can give would be greatly appreciated. Thanks!
|
|
|
|
|
From where your web application is running ? Is it from VS IDE or from IIS ?
If it is from IIS, did you set the ASP.NET version on Virtual Directory ?
Please let me know. I will try to help you out !!
and Happy new year !!
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
Good question. I just published the website to a local folder on my computer and ran it from there, but I get the same error when I upload and run it from the online server as well.
|
|
|
|
|
Sorry for late response. Does your problem resolved ?
Happy new year !
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
No it's not resolved yet, but I think I might need something extra in my webspace to help the browser run the VB code than just the .aspx file. So any suggestions are welcome.
Actually correction, I don't know how to get the website I designed in VB to a finished product that I can put on the webspace I have. When I try to and then run the result in a web browser I get the aforementioned error.
modified on Wednesday, January 6, 2010 9:22 PM
|
|
|
|
|
Hi all,
i am developing one website, in which i have following code,
function GetCatDesc(Int)
{
var vardesc= "";
switch (Int)
{
case 1:
vardesc += "Employements";
break;
case 2:
vardesc += "Automobiles";
break;
}
return vardesc;
}
and
<tr><td align="left" ><asp:Label runat="server" Text="GetCatDesc(<%#Eval("fao_ddlcategory")%>"></asp:Label></td></tr>
for this label the value will be coming while page loading or some other on search click.
i want that function to be executed and the result of that function to be set as text for the label.
i dont know the asp syntax, can any one help me,
thanks in advance
|
|
|
|
|
just put
Text = javascript:GetCatDesc('<%# Eval("fao_ddlcategory")%>'"
instead of what you have.
The execution depends on where you added this server control. #Eval works in Repeater, but you cant do this in a server side control I think.
Check with this solution. Hope it corrects. Otherwise ask me with the whole control where you placed this Eval.
|
|
|
|
|
what ever you said is correct,
i m using the same in the repeater only.
<asp:repeater id="rptProducts" runat="server" >
<ItemTemplate>
<table cellpadding="5" cellspacing="0" style="background-color:lightyellow">
<tr>
<tr><td><asp:LinkButton runat="server" ID="i" OnClientClick="mypopup()" CommandName=<%#Eval("fao_addsnumber")%> > <%#Eval("fao_subcategory")%> </asp:LinkButton></td></tr>
<tr><td align="left" ><asp:Label runat="server" Text="javascript:GetCatDesc(<%#Eval("fao_ddlcategory")%>"></asp:Label></td></tr>
<tr><td align="left"><%#Eval("fao_description")%></td></tr>
<tr><td align="Left"><%#Eval("fao_city")%> <%#(" ,")%> <%#Eval("fao_state")%> <%#(" ,")%> <%#Eval("fao_country")%></td>
<%--<asp:HiddenField runat="server" ID="test" Value=<%#Eval("fao_addsnumber")%>/>--%>
</tr>
</tr>
<br />
<br />
</table>
</ItemTemplate>
</asp:repeater>
this is my coding regarding the function..
i added label for checking , its not working though..
even after removing that also its coming like text javascript:GetC...
like this
thans for ur response
|
|
|
|
|
Ya, I got your problem. Actually, if you dont place runat=server for a control inside Repeater, it will evaluate data correctly. For a control having runat="server" you need to do this from your codeBehind.
The ItemDataBound event is the best candidate for you.
Add asp:Repeater OnItemDataBound="RepeaterItemEventHandler" in the control
public void RepeaterItemEventHandler(object sender, RepeaterItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternateItem)
{
Label lbl = e.Item.FindControl("lblitem") as Label;
lbl.Text = DataBinder.Eval(e.Item.DataItem, "fao_subcategory");
}
}
also to remind you, you can set the javascript there, but it will not execute when text property gets loaded. Rather put a RegisterStartupScript which will modify the data.
this.ClientScript.RegisterStartupScript(this.GetType, lbl.ClientId, "GetCatDesc('" + lbl.ClientId + "');" , true);<br />
like this.
Just modify this according to what you need. Do this inside the RepeaterItemEventHandler
|
|
|
|
|
thanks abishek,
i agree and i will work and revert you as per the method you said,
but my question is you said putting runat="server" i.e server side control cannot be used directly inside the repeater, look below
<tr><td align="left" >javascript:GetCatDesc(<%#Eval("fao_ddlcategory")%>)</td></tr>
<tr><td align="left"><%#Eval("fao_description")%></td></tr>
here the description is printing correctly and why not my funcion??
i have doubt on this can you clear me please if u dont mind,
and am sorry if i disturb you.
and
lbl.Text = DataBinder.Eval(e.Item.DataItem, "fao_subcategory");
in this line am getting
Error 26 Cannot implicitly convert type 'object' to 'string'. An explicit conversion exists (are you missing a cast?)
thanks in advamce
modified on Thursday, December 31, 2009 2:16 PM
|
|
|
|
|
Hema Bairavan wrote: you said putting runat="server" i.e server side control cannot be used directly inside the repeater
what... No no. You can put runat="server" control inside ItemTemplate of a Repeater and only those controls that you state runat="server" could be found during ItemDataBound Event.
I said you cant specify server tags in the designer when you place runat="server"
<asp:Label runat="server" Text="<%# Eval("fao_ddlcategory")%>" is not possible
rather
you use
<span><%# Eval("fao_ddlcategory")%>" </span> which is client side control, or rather you directly place in the TD block.
Hema Bairavan wrote: here the description is printing correctly and why not my funcion??
Ya.. It will print. Actually writing javascript:func in the html is meaningless. javascript protocol is used to define that the line prior to it is a javascript one. If you want to place/run a script, place it below all controls in a script block like
<script type="text/javascript">
GetCatDesc(val);
</script>
If you place your javascript in RegisterStarupScript it will appear at the bottom of the page and thus find all the control in it.
Hema Bairavan wrote: in this line am getting
Error 26 Cannot implicitly convert type 'object' to 'string'.
Yes of course, you must do
lbl.Text = DataBinder.Eval(e.Item.DataItem, "fao_subcategory") as string;
Hope you get the issues right..
Happy New Year from me.
|
|
|
|
|
I don't know until the page is created how many radiobuttonlists I will need. So, I create them and store the number in a hidden label. But, when I want to get the selection from the radiobuttonlist on postback, I keep getting a object reference error. I've tried finding the control without a findControl, with a findControl and with a master page content reference and findControl. No luck. Any help appreciated...
Dim myConStr As String = ""
If lblSidCount.Text <> "0" Then
Dim x As Integer = 1, y As Integer = Convert.ToInt32(lblSidCount.Text)
Do While x <= y
Dim myContent As ContentPlaceHolder = CType(Page.Master.FindControl("ContentPlaceHolder1"), ContentPlaceHolder)
Dim radConStr As New RadioButtonList
radConStr = CType(myContent.FindControl("rad" & x.ToString), RadioButtonList)
myConStr &= radConStr.SelectedItem.Text & "~"
x = x + 1
Loop
myConStr = Left(myConStr, Len(myConStr) - 1)
End If
|
|
|
|
|
This seems to work - am I crazy for doing this?
Private radCon As RadioButtonList()<br />
Protected Overrides Sub OnInit(ByVal e As EventArgs)<br />
MyBase.OnInit(e)<br />
If (Request("str") = 1) Then<br />
Dim myList As dsSql = New dsSql() ''''instantiate the function to get dataset<br />
Dim ds As New Data.DataSet<br />
ds = myList.dsConSessionTimes(Request("eid"))<br />
If ds.Tables("conSessionTimes").Rows.Count > 0 Then<br />
radCon = New RadioButtonList(ds.Tables("conSessionTimes").Rows.Count - 1) {}<br />
Dim i As Integer = 0<br />
Dim rad As RadioButtonList = New RadioButtonList()<br />
rad.ID = "rad" + i.ToString()<br />
rad.DataSource = ds.Tables("conSessions")<br />
rad.DataTextField = ds.Tables("conSessions").Columns("session_name").ToString<br />
rad.DataBind()<br />
rad.SelectedIndex = 0<br />
phConcurrent.Controls.Add(rad)<br />
radCon(i) = rad<br />
For Each j As Data.DataRow In ds.Tables("conSessionTimes").Rows<br />
Dim rad As RadioButtonList = New RadioButtonList()<br />
rad.ID = "rad" + i.ToString()<br />
rad.DataSource = ds.Tables("conSessions")<br />
rad.DataTextField = ds.Tables("conSessions").Columns("session_name").ToString<br />
rad.DataBind()<br />
rad.SelectedIndex = 0<br />
phConcurrent.Controls.Add(rad)<br />
radCon(i) = rad<br />
i = i + 1<br />
Next<br />
End If<br />
End If<br />
End Sub
|
|
|
|
|
Hi, I am trying to build a website that provides stock information like the one in Yahoo Finance:
http://finance.yahoo.com/echarts?s=MSFT#chart7:symbol=msft;range=3m;indicator=bollinger+volume;charttype=line;crosshair=on;ohlcvalues=0;logscale=on;source=undefined
All the source and analytical data is already there, however I am trying to implement a mechanism that allows users to click and graph additional chart on each mouse click, meaning there'll be multiple postbacks. The problem is with each postback, existing charts plotted by users should remain on the page, and only the new chart is added.
In the link above, if you click on "TECHNICAL INDICATORS", a dropdown list appears allowing users to add additional chart to the page, without destroying existing charts that's currently on the page. This is exactly the kind of function I want to have for my website.
So how could I implement this mechanism using ASP.NET? I am thinking this is a Viewstate issue. Should my goal be maintaining the viewstate of the chart itself? Or should I perhaps store user-defined inputs temporarily into a control (perhaps a label control)and maintain the viewstate of that, based on which the chart will be plotted?
Or is there a more elegant approach to this?
I'd greatly appreciate any suggestions! Thank you.
|
|
|
|
|
Could someone please give me some suggestions if possible? Thanks!
|
|
|
|
|
Try using ajax and avoid postback.
Asp.Net Ajax provides you a number of ways to stay on the page and add
contents to the same page from the server.
Hope this will help.
|
|
|
|
|
Thanks for the reply Anurag. I thought with AJAX, there'll still be postbacks, just partial postback in the AJAX panel? Thus if I put my chart in the panel, it'll still post back and redraw the chart every time I click the "ADD New Chart" button right?
Thanks!
|
|
|
|
|
Hi,
Ajax doesn't always mean UpdatePanel.
When user clicks add new chart, Create a new XmlHttpRequet,
Send the request for the new chart to the server,
Get the new chart as a response from the server,
Then, add it to your page using javascript.
Postback is not needed in this case.
You may need to go through tutorials or book if facing problem.
|
|
|
|
|
Hi All,
Hope everyone had a Merry Xmas and Happy New Year.
Just a question...I have made an RSS Feed which is syndicated by the Mozilla and IE , as an output of an XML file. However when either of the feeds show, they show the pubDate as being totally different dates to what is shown in the XML file. Even when I look at the source, the XML file still shows the correct dates as opposed to what is shown in the browser.
What do you guys think is the problem? Heres my code. Cheers.
public static void CreateNewsFeed(string mappath)
{
FileStream fs = null;
StreamWriter sw = null;
try
{
using (SqlConnection conn = Connection.connect())
{
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandText = "ShowNewsFeed";
cmd.CommandType = CommandType.StoredProcedure;
SqlDataReader reader = cmd.ExecuteReader();
fs = new FileStream(mappath, System.IO.FileMode.Create, System.IO.FileAccess.Write);
sw = new StreamWriter(fs);
sw.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
//ISO-8859-1
//xmlns:atom=\"http://www.w3.org/2005/Atom\"
sw.WriteLine("<rss version=\"2.0\">");
sw.WriteLine("<channel>");
sw.WriteLine("<title>Company Name</title>");
sw.WriteLine("<link>http://www.companyname.com.au/Home/News/News.aspx</link>");
sw.WriteLine("<description>News and the latest updates</description>");
sw.WriteLine("<language>en-us</language>");
while (reader.Read())
{
DateTime dt = (DateTime)reader["datePosted"];
sw.WriteLine("<item>");
sw.WriteLine("<title>" + reader["title"].ToString() + "</title>");
sw.WriteLine("<link>http://www.companyname.com.au/NewsArticle.aspx?newsID=" + reader["newsID"] + "</link>");
sw.WriteLine("<description>" + reader["description"].ToString() + "</description>");
sw.WriteLine("<pubDate>" + dt.ToString("R") + "</pubDate>");
sw.WriteLine("</item>");
}
sw.WriteLine("</channel>");
sw.WriteLine("</rss>");
sw.Close();
fs.Close();
}
}
catch (Exception m)
{
throw new Exception(m.Message);
}
}
|
|
|
|
|
HELLO All
Recently i found this article about reporting with word document ,when i used the sample code it's working fine ,but rather plain , what if i want spice my report , i have an already designed word reports ,they are simple forms , when i saved them as XML i got this lengthy xml file ,now of course i have some blank cells , in the reports that i want to fill since the report is basically a table , here comes the headache ,HOW TO GET TO THE PARTICULAR NODE? i have solved this problem in a hard way i wonder if there is a better way DOES ANY1 KNOW AN EASIER WAY TO GET TO THE NODES AND OVERWRITE THEM? ANY GOOD ARTICLE ABOUT THIS TOPIC
THANX IN ADVANCE
by the way here is the hard solution of mine ,i first read copy xml file into .txt file then read it and indexof() the cell to know where is it exactly i want to insert my data the code would like like this
fp = File.OpenText("C:\Documents and Settings\Administrator.RFF-SRV0\Desktop\" & "NoteVactionXML.txt")
_ManipulationStr = fp.ReadToEnd()
Dim str, resl As String
resl = _ManipulationStr
Dim index As Integer = 0
str = "<w:r w:rsidrpr="" 00ea5324""="">" _
& "<w:rpr>" _
& "<w:rfonts w:cs="" simplified="" arabic""="">" _
& "<w:b>" _
& "<w:bcs>" _
& "" _
& "<w:t>" & "خن" & "" _
& ""
resl = resl.Insert(548 + 10566, str)
fp.Close()
strHTMLContent.Append(resl)
HttpContext.Current.Response.Write(strHTMLContent)
HttpContext.Current.Response.End()
HttpContext.Current.Response.Flush()
Do i have to do the above for each item?
I HOPE NOT
|
|
|
|
|
you are a very bold person
I am assuming you have an xml-document :
.Net has some classes you want : XmlReader and XmlDocument .
A search for those terms should give you plenty articles to read.
|
|
|
|
|
how creat word document in asp.net use by vb.net
|
|
|
|