iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
Hi,
I want to add an image to Columns 0 then on click run javascript code.
When using a hyperlink another page opens no matter what target I use. I only need an image and javascript to run, no hyperlink.
Can you tell me how to have an image column and run javascript on click?
protected void WebGrid1_InitializeRow(object sender, ISNet.WebUI.WebGrid.RowEventArgs e) { WebGrid1.RootTable.Columns[0].ColumnType = ISNet.WebUI.WebGrid.ColumnType.HyperLink; WebGrid1.RootTable.Columns[0].HyperlinkDisplayText = " <img onclick=\"msgbox3('Tools Update','ToolsAdminUpdate.aspx?id=" + e.Row.Cells[0].Text + "','500px','420px')\" style='border:0; width:35px' alt='" + "?id=" + e.Row.Cells[0].Text + "' src='Images/edit.png'/>"; WebGrid1.RootTable.Columns[0].HyperlinkTarget = ISNet.WebUI.WebGrid.HyperlinkTarget.UseBase; }
Hello,
It would be easier if you use Custom column. You can combine any type/script in there.
e.g
if (e.Row.Cells.GetNamedItem("CustomerID").Text == "ALFKI") { e.Row.Cells.GetNamedItem("Test1").Text = "<a href='http://google.com'> <img alt='HyperLink' src='../../images/1.gif'/>"; }
Regards,Handy
Thank you this works.
Can you send me an example on how to create a custom column using a ASP Control and capture the on click event? So take the the example above where I add an html image and on click I capture the javascript event. Now I want to be able to capture the server on click event.
How do I add a server side control and how do I capture on click event? The built in image button doesn't fit my needs.
Thanks
Andre
Hello Andre,
I guess you want to have image button that have click serverside event, correct? If that so, why don't you use our WebGrid ButtonImage type column?
To trigger its server side, simple set the autopostback true.
<ISWebGrid:WebGridColumn Caption="ButtonImageColumn" ColumnType="ButtonImage" EditType="NoEdit" Name="ButtonImageColumn" Width="100px" ButtonAutoPostback="True" ButtonPostbackMode="FullPagePostback"> </ISWebGrid:WebGridColumn>
I have tried to use that buttonImagecolumn. The problem is their is a square around the image like it's a button, the Onclick event is fired on mouse down, not up, I can't resize the image (not sure how) and I also need to call a javascript Alert box first.
So I figured If you could tell me how to just use a typical asp:imagebutton I could fix all my issues. I just need to know how to add it to the grid and know what button is being fired on postback.
As far I know, you could not use asp button for your scenario. To trigger server side event, you need to use AutoPostBack true. In this state, any click clientside event would be ignored because it got postback first.
Also, I am not sure about what did you mean by "I can't resize the image". Does this mean, that button size is not fit with the row height? If that so, to make it automatic size became fit, simple set RowHeightDefault to -1.
In order to fullfil your scenario, I think you might want to try WebButton. Our WebButton has some advantages than the default button.You can set the display as image button. Also, you can also trigger flypostback.In this state you should able call your serverside event plus your clientside event.
<ISWebGrid:WebGridColumn Caption="ButtonImageColumn" ColumnType="Template" EditType="NoEdit" Name="ButtonImageColumn" Width="100px" ButtonAutoPostback="True"> <CellTemplate> <ISWebDesktop:WebButton ID="WebButton1" runat="server" Height="20px" Text="TES" AutoPostback="True" onclicked="WebButton1_Clicked" OnClientClick="WebButton1_OnClientClick"> </ISWebDesktop:WebButton> </CellTemplate> </ISWebGrid:WebGridColumn>
can you give me an example where the webgridcolumn goes in the html?
<ISWebGrid:WebGrid <LayoutSettings>
???
</LayoutSettings> </ISWebGrid:WebGrid>
What do you mean? As I described in my previous posted, I have some though regarding your requirement.
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname