|
That Would be correct.
Now if you research the concept a little further you will be able to figure out how to use the same concept to display a shortened date.
i.e
<%# DataBinder.Eval(Container.DataItem, "blah", "{dd/MM/YY}") %>
A good idea would be for you to research the concept now that I have given you, to see how you can improve on it. This would help to improve your coding abilities and understanding?
|
|
|
|
|
Hey,
Set the dataformatstring propery for that column equals "{0 }" and HTMEncode property = false. This will work
|
|
|
|
|
hi,
i have need a functionality like as soon we click the button at the moment that button will hide and after that the functionality should fire written in code behind along with that button.i am working as follows;
<script language="javascript" type="text/javascript"><br />
function check()<br />
{ <br />
document.getElementById('Button1').style.visibility= "hidden"; <br />
return false;<br />
}<br />
</script><br />
code behind as follows:
<br />
protected void Page_Load(object sender, EventArgs e)<br />
{<br />
Button1.Attributes.Add("onclick", "javascript:return check()");<br />
}<br />
<br />
protected void Button1_Click(object sender, EventArgs e)<br />
{<br />
Response.Write("success");<br />
}<br />
this not working properly.
and i have to do this for a content page having this Button1 so the problem is the the getElementById is not working.
Regards,
Srinandan..
|
|
|
|
|
When the HTML is written out to the Page, your button's ID in the HTML probably isn't "Button1". That means your javascript method will fail.
To get around this, write the javascript into a String on the Server-Side and add it to the Page by using the RegisterClientScriptBlock method. When inserting the Button's ID, use MyButton.ClientID to get the correct id.
|
|
|
|
|
if you say
return false;
the page will not submit
Regards,
Sylvester G
sylvester_g_m@yahoo.com
|
|
|
|
|
thanks for reply
if i will make the return true then the button will hide for moment but i have need to hide for that time.
srinandan..
|
|
|
|
|
when the button again want to visible for you?
Regards,
Sylvester G
sylvester_g_m@yahoo.com
|
|
|
|
|
thanks Sylvester
As soon the button will click at the moment it should be hide after that the Button1_Click() events should fire. in this method i am check some condition if the functionality goes success then no need to show that button if functionality failure then the button should visible
its all.
regards,
Srinandan
|
|
|
|
|
in the catch block
you can make the button visible like the following line
Button1.Visible = true;
Regards,
Sylvester G
sylvester_g_m@yahoo.com
|
|
|
|
|
hi Sylvester
I am doing this but this is not my problem.the problem with me when the button goes hidden in client the the server code is not firing.
Regards,
Srinandan..
|
|
|
|
|
In order to ensure that controls have a unique id on the page, ASP.NET will rename your controls as it renders them. In order for you to retrieve the id of a server control on the client side, you will need to progratically reference the ClientID property of the button.
Using the ClientID property, you could refactor your code into something like:
Client Script:<script language="javascript" type="text/javascript"> function check(buttonId) { button = document.getElementById(buttonId); if (button) { button.style.visibility = "hidden"; } return false; } </script>
Server Code:protected void Page_PreRender(object sender, EventArgs ea) { button1.Attributes.Add("onclick", String.Format("javascript:return check({0});", button1.ClientID)); }
You'll notice that I moved your setting of the button's attribute ito the PreRender event handler. One thing to keep in mind is that a control's client-side id is not final until it, and all of its parents, are added to the page's control tree. In order to accomodate control manipulation, I usually try to reference the ClientID as late in the render cycle as possible.
What I would recommend in your case, however, is simply to pass a reference to the button into your javascript function. This would eliminate any need to use getElementById at all, instead simply manipulating the reference. To do so, you could refactor into something like:
Client Script:<script language="javascript" type="text/javascript"> function check(button) { if (button) { button.style.visibility = "hidden"; } return false; } </script>
Server Code:protected void Page_Load(object sender, EventArgs ea) { button1.Attributes.Add("onclick", "javascript:return check(this);"); }
Hope that helps.
--Jesse
"... the internet's just a big porn library with some useful articles stuck in." - Rob Rodi
|
|
|
|
|
thanks you Jesse
but problem with here when return false then the server code is not firing
i have need to visible=hidden in client and then fire the server code
Regards,
Srinandan
|
|
|
|
|
I'm sorry, I must have misunderstood your post. If you'd like the server code to fire, simply change the javascript function to return true instead.
--Jesse
"... the internet's just a big porn library with some useful articles stuck in." - Rob Rodi
|
|
|
|
|
thanks Jesse
my problem has been solved if rmove the return value or return the true.
thanks for making reply.
Regards,
Srinandan
|
|
|
|
|
Hi, I’m somehow new to user controls in asp.net plz help me out!
I’ve two major problems with the following code:
protected void Page_Init()
{
for (int i = 0; i < 10; i++)
{
ctrl_new_friend temp_new_friend = (ctrl_new_friend)LoadControl("ctrl_new_friend.ascx");
temp_new_friend.ID = "ctrl_new_friend_" + i;
// >> For Debugging Purposes And Should Be Replaced By Data From DB
temp_new_friend.image_name = "hamed";
//End Debugging <<
ph_new_friends.Controls.Add(temp_new_friend);
Image img_separator = new Image();
img_separator.ImageUrl = "~/anonsec/misc/xuniv_separator_blue.gif";
ph_new_friends.Controls.Add(img_separator);
}
}
First: It works fine but sometimes – mysteriously - get an “Unable to cast” error;
Second: It doesn’t seem to be performance friendly, and if I put the LoadControl() outside of the for() block it adds the control just one time.
I think I’m making a mistake using such coding!
Thanks for your help.
|
|
|
|
|
Hi,
I wanna create an Excel file cell by cell with formating in asp.net.
I have data in dataset or in HTML file.Now is there any way through which i could transfer the data in HTML in same format in excel.
If i have to do it through Dataset to Excel then i need a method through which i could access each cell of excel.Else i need a method through which entire HTML can be transfered in Excel with all its format.
Can any1 have the solution....Thnx...
|
|
|
|
|
There are a few ways that you can go about this, depending on how complex your spreadsheet and formatting needs are. In a simple case, the approach that you mention of forming HTML and tricking Excel into parsing it, is a good one. There are plenty of articles available if you care to google, but the basic implementation involves you setting header values from your page. For example:
Response.AddHeader("content-disposition", "attachment; filename=MyExcelSheet.xls"); Response.ContentType = "application/ms-excel";
That technique only works if the formatting is simple. If you require more advanced formatting or the use of formulas, you may wish to consider purchasing one of the commercial components that allow you to work with the Excel native format without Office being present on the machine, such as this[^] one.
As a last resort, it is possible to install Office on the server and use the Office interop assemblies to automate Excel. Please note that I label this the last resort, because it is slower, consumes more resources, and requires client software to be installed on a server (potentially increasing the attack surface.)
Hope that helps.
--Jesse
"... the internet's just a big porn library with some useful articles stuck in." - Rob Rodi
|
|
|
|
|
Thnx for your reply....
i got this article from net but still not even able to create an object of application...i have included ref of excel object too...dont knw why Application object in first line now created...
code is as follows:-
In this article, we are going to see how to open a write a dataset to a excel file and open the excel file in the browser.
In order for this to work, there is an important modification in web.config file. We have to add <identity impersonate="true"> else you will get an 'Access is denied' error.
In the application, we have to add a reference for a COM component called "Microsoft Excel 9.0 object library".
Now we have to just loop through the dataset records and populate to each cell in the excel.
Code:
private void createDataInExcel(DataSet ds)
{
Application oXL;
_Workbook oWB;
_Worksheet oSheet;
Range oRng;
string strCurrentDir = Server.MapPath(".") + "\\reports\\";
try
{
oXL = new Application();
oXL.Visible = false;
//Get a new workbook.
oWB = (_Workbook)(oXL.Workbooks.Add( Missing.Value ));
oSheet = (_Worksheet)oWB.ActiveSheet;
//System.Data.DataTable dtGridData=ds.Tables[0];
int iRow =2;
if(ds.Tables[0].Rows.Count>0)
{
// for(int j=0;j
|
|
|
|
|
What you're attempting to do in that code is to use COM interop to automate the Excel client. You are most likely failing because Excel is not installed on your web server. As I mention in my original reply, I'd strongly recommend that you use this approach only as a last resort.
Please refer to my original reply for some alternatives.
--Jesse
"... the internet's just a big porn library with some useful articles stuck in." - Rob Rodi
|
|
|
|
|
hi
i have a multiple selection listbox in the webform. i want to add the items of the listbox into a database, where in each item goes in a particular column.
i am implementing this using arrays. but wat i am not getting is how should i declare an array for the listbox.
i have declared an string type array with size 6, cuz i dont want more than 6 values to be selected.
finally, how shud i implemnt it...
string[] list = new string[5];
Kunal Piyush
|
|
|
|
|
I am clicking login button which is on home page.then login page comes up. After login that login button converted into logout on home page and at time if I clicked on the browser BACK button I get login page.But I am already logined, So I don't want that page when logout button is active on home page.
yog
hui gfgh kgdgrt njjn hjgkn
|
|
|
|
|
u will need to maintain sessions or cookies to obtain this functionality. this would add more security. also now if u logout and click a back button, you wont be redirected to the logged in home page.
Kunal Piyush
|
|
|
|
|
heay kunal....could u send some artiles relateing to this stuff
or the procedure to follow ...!
|
|
|
|
|
yuva..read the msdn documentation.. session states
there u will get exaustive info about the same.
Kunal Piyush
|
|
|
|
|
Thank you for reply.
I have used javascript
Window.history.go(+1)
in order to prevent user from going to the signin page .
Currently I'm not getting sign in page in all conditions whether user is logged in or not.
But I want this to happen only when user is already logged in .
I have maintained session for userid when user is logged in.
But don't understand how to restrict this code to execute only when user is logged in.
yog
hui gfgh kgdgrt njjn hjgkn
|
|
|
|