|
Hi,
When my page is in it's Page_Load method (in my code behind file) I need to get inner HTML of a certain element. Actually I need the HTML that my repeater control produces and then save it to a string.
How can I do this? Is the HTML even generated yet at the point in time when Page_Load is called? If not, I can wait 'till anytime in execution, I just need to get the HTML of the repeater control into a string in my code behind file.
/\ |_ E X E GG
|
|
|
|
|
figured it out. I just added a flag to my method that builds the
repeater and added this code to the bottom of that method:
if (render)
{
StringBuilder sb= new StringBuilder();
StringWriter sw= new StringWriter(sb);
HtmlTextWriter hw= new
HtmlTextWriter(sw);
RepeaterPapers.RenderControl(hw);
return sb.ToString();
}
So if render is true, it will return immediately with the html of the
repeater!
/\ |_ E X E GG
|
|
|
|
|
hi to all
I have datagrid with 9 records.i have 3 buttons named as ,view all ,Active,Deactive.
Here my database columns are country,company,logo,status.
If i click view all the records can be viewed pagewise without any error. It is working fine.
The other 2 buttons namely:
Button Active-status is 1
Button DeActive-staus is 0
I have set pagesize= 5 , that is i have 5 records(1,2,3,4,5) in the first page,4 records(6,7,8,9) in second page.
In the first page i have 3 active records (1,3,5), and two deactive records(2,4)
if i click active in the first page only 3 active(1,3,5) should be displayed and if i click deactive only two deactive records (2,4) should be displayed. Instead all the active records(including active records in second page) are also displaying in that page and same problem in deactive also.
similarly,
In the second page i have two actve records (7,9), and two deactive records(6,8)
if i click active in the second page only 2 active(7,9) should be displayed and if i click deactive only two deactive records (6,8) should be displayed. Instead all the active records(including active records in first page) are also displaying in that page and same problem in deactive also.
My question is i have to display only the active records in the first page.I have set overall pagesize as 5 in my datagrid. How can i set to display only the 3 active records and two deactive records in the first page and same for second page .
I have given the code for Active & Deactive below
ACTIVE BUTTON: (status 1)
Try
strConnString = objCsLgateway.GetConnectionString()
conn = objCsDataBase.GetDbConnection(strConnString)
Dim adap As New SqlDataAdapter("select DISTINCT logo_code,company_name,country_name,category,picture_path from tblLogos where status=1 ", conn)
Dim ds As New DataSet
adap.Fill(ds, "tblLogos")
DataGrid1.CurrentPageIndex = 0
DataGrid1.DataSource = ds
DataGrid1.DataBind()
Catch errEx As Exception
Response.Write(errEx.Message)
End Try
DEACTIVE BUTTON (status 0)
Try
strConnString = objCsLgateway.GetConnectionString()
conn = objCsDataBase.GetDbConnection(strConnString)
Dim adap As New SqlDataAdapter("select DISTINCT logo_code,company_name,country_name,category,picture_path from tblLogos where status=0 ", conn)
Dim ds As New DataSet
adap.Fill(ds, "tblLogos")
DataGrid1.CurrentPageIndex = 0
DataGrid1.DataSource = ds
DataGrid1.DataBind()
Catch errEx As Exception
Response.Write(errEx.Message)
End Try
plz provide me with proper solution and the corrected code.
|
|
|
|
|
|
Hi All,
I have registered javascript function form Page_Load method in my User control.
Is there any way to tell web page which my control belongs to to call this function from body onload event ? I do not have access to the web page and would like to do it from user control.
Thank you very much
Roman
|
|
|
|
|
Hi there,
From the web user control, you can access the web page using the Page property and do what you want. Another option is that the user control can provide an event and have the web page containing the control do the job for the control.
|
|
|
|
|
I have a link for users to download a particular image from my server.
The link control basically looks like the following:
lnkMyImageLink.NavigateURL = "\\serverName\rootFolder\sub2\Folder\images\imagename.tif";
IE seems to know this represents a full filepath however Firefox interprets this as:
"http://www.mySiteName.com/\\serverName\rootFolder\sub2\Folder\images\imagename.tif"
Any idea how to inform Firefox that this is a full image filepath? It's interesting because if you right click in firefox and do a "View Source", the "href" tag looks like "href=\\serverName\rootFolder\sub2\Folder\images\imagename.tif", so I would think that should work but apparently not.
Thanks.
-Goalie35
|
|
|
|
|
I think that because windows explorer and internet explorer are so intwined, when you pass ie a \\servername link, it "converts" itself to windows explorer and handles the link accordingly (e.g. the same as typing it into start > run box). Firefox I don't think can do this. e.g. Type c:\ into the address bars of ie and ff. IE you get standard windows explorer, FF you get a file:/// link and an html representation.
Good luck if you find a solution - I'd be interested myself.
ChrisB
|
|
|
|
|
ChrisB,
You mentioned you were interested in knowing the solution to my problem so here it is:
It actually turns out that although IE accepts this filepath as valid, it's not a good approach to take. So as a different approach, the key is to create a new webpage with the content type set to "application/octet-stream"
-I have a link on my initial page that reads "Click to download file".
-Link to a new aspx webform(I named mine "Download.aspx") & place the url to the downloadable file within either the URL or a session object (mine is within a session).
-Add this code to "Downloader.aspx":
-------------------------------------------
using System.IO;
protected void Page_Load(object sender, EventArgs e)
{
String filepath = Convert.ToString(Session["fileUrl"]);
String filename = Path.GetFileName(filepath);
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename=" + filename);
Response.Flush();
Response.WriteFile(filepath);
}
------------------------------------------------
That solved my problem.
-Goalie35
|
|
|
|
|
Goalie35 wrote: the key is to create a new webpage with the content type set to "application/octet-stream"
Of course ! The same method as retrieving an image from a database (like a loadImage.aspx?id=123 page) - replace the page content with the content you actually want to supply.
Thanks for that.
ChrisB
|
|
|
|
|
I've googled etc... but can't find anything relevant.
I have a user control in a master page.
The user control access a session variable which may or may not exist.
If it doesn't exist, the user control doesn't display any content. If it does exist, it displays content.
The problem is that when a page creates the session variable in the postback, the user control is already created and at the time the user control code ran, the session variable didn't exist. This means that although the session variable exists, the user control is not displayed until the user navigates to the next page.
Is there any way to force a user control (which is in the master page) to load after the page code has run?
Thanks
ChrisB
|
|
|
|
|
You can have a method in your usercontrol to reread value of session variable. You can call this method in your code after you write value to a session.
Or you can override Render (or OnPreRender) method of your user control to reread session variable.
These methods are called after postback handlers, so your variable stored in session should already has desired value.
I like this solution more.
class MyControl : UserControl
{
...
...
...
protected override OnPreRender(EventArgs e)
{
// read value from session
SetContent(Page.Session["MY_SESSION_VARIABLE"].ToString());
base.OnPreRender(e)
}
}
Pilo
|
|
|
|
|
|
i use .NET 1.1
im my web site i have a HtmlInputFile
when i upload a small file that's ok
but when i want to upload big files it isn't work
and display "The page cannot be found"
how can i solve it ?
With thanks
MHF
|
|
|
|
|
It sounds like your browser is timing out before the upload has time to finish. You could try displaying an "uploading" page whilst the upload happens, though without your code it is diificult to say exactly what is going on
|
|
|
|
|
is there any where that limit the size of file ?
i use i use
HtmlInputFile.PostedFile.Write Method
MHF
|
|
|
|
|
yes there is a limit on the size of the file, it can however be changed see -
here
|
|
|
|
|
Thanks It is so Useful
MHF
|
|
|
|
|
There are three textboxex. I have given values in textbox1 and textbox2 as 10 and 20. if I hit the enter key not tab control the sum of two textboxes(30) will be displayed in textbox3. How can I write on client side using javascript? if anyone send code its nice.
thanks,
Hosanna.
|
|
|
|
|
You can use var elem = document.getElementById(id) to retrieve your text box element, then use elem.value = "whatever" to set its value.
See if you can figure out how to trigger the code. (Hint: you're probably wanting to investigate keyboard events for the text box element)
|
|
|
|
|
In my database contain path to image.Ther r N number of images.
I need to dynamically creat Image box and load image to it.
is there any way???
All I ever wanted is what others have....
CrazySanker
|
|
|
|
|
foreach(string imagePath in arrayOfMyImagePaths)
{
Image image = new Image();
image.ImageUrl = imagePath;
myPlaceholder.Controls.Add(image);
}
<asp:Placeholder id="myPlaceholder" runat="server"/>
... and so on.
Pilo
|
|
|
|
|
For each site, it should display the name of all the web parts contained in that site.mine is a asp.net application with c# as codebehind and developed in .net 1.1
thanks.
|
|
|
|
|
Hi,
I am want to create an Ajax page, can any one suggest me what are the requirments need to develope an Ajax site with ASP.NET with VB.NET.
Know is Drop, Unknown is Ocean
|
|
|
|
|
Hi,
You can download Ajaxpro DLL .. or you can use HTTPRequest object directly to use AJAX
Thanks,
Sushant Duggal.
|
|
|
|