Hello all,
I have an ultrawebgrid that has many rows and many columns. On the Task column, I have embedded an asp.net 2.0 LinkButton and in there I have the link to open up a .aspx modal. The modal does opens up on the second click on the Link Button. After the first click it seems to initialize the link opens up the modal and after that when I tried to opens up the modal again on that same row, it will open up on the first click. And if I were to go onto the second row and click the link for the first time, it would not open up the modal, but on the second click, third click , and so on (on that second row), then it will open up the modal.
So my question is, how do I initialize the link to the modal on either Page_Load, InitializeLayout or InitializeRow event methods. I have tried it on all three but none of them work because it cannot find the instance of my asp.net LinkButton.
It seems like, it will only initialize the modal link when it invoke the LinkButton1_Click event.
LinkButton1_Click (object sender, EventArgs e)
{
//Create an instance of the LinkButton
LinkButton lnkButton = (LinkButton) sender;
//some javascript function
script = "javascript code here";
Page.ClientScript.RegisterStartupScript(typeof(Page), "modalDlg", script);
lnkButton.Attributes.Add("onClick", "doIt();"); // doIt(); is the javascript function from the "script" block two lines above
}
I have tried using FindControls ("LinkButton1") but it cannot find it in neither Page_Load, InitializeLayout or InitializeRow.
If someone knows how to solve this, please shred some light on me.
Thanks very much in advance!
Hs2
Hello,
Sorry for replying so late b/c i wasn't able to check email.
Design:
What you need to do is actually really simple: In your webgrid, create a templatedcolumn and use an asp:LinkButton
<igtbl:TemplatedColumn AllowUpdate="No" Key="TestColumn"> <CellTemplate> <asp:LinkButton ID="lBtnTest" runat="server" Text="Test" OnClick="lBtnTest_Click" /> </CellTemplate> <Header Caption="Test Column"> <RowLayoutColumnInfo OriginX="9" /> </Header> <Footer> <RowLayoutColumnInfo OriginX="9" /> </Footer> </igtbl:TemplatedColumn>
C# Code in behind:
In your C# code, you inside the linkbutton event,
protected void lBtnTest_Click(object sender, EventArgs e){
string sScript = null;
string sHeight = 400px; // or whatever size you want your modal to be
string sWidth = 400px; // or whatever size you want your modal to be
//If you need to pass any data to the modal then do it in the line below after the sTitle variable
sScript = "<script>var rc=new Array(0,0); rc=window.showModalDialog('Test.aspx?Title=" + sTitle + "','','dlgHeight:" + sHeight + " px;dlgWdith:" + sWidth + " px');" + "\n";
//this line of code handle the case where I want to return a value back to parent screen from the modal sScript += "if(rc!=null){document.getElementById('returnvaluetoparentscreen').innerText=rc[0]; __doPostBack('','');}</script>";
//This line of code register the script
this.ClientScript.RegisterStartupScript(typeof(Page), "showModalDialog", sScript);
If you just take this code and follow my example, it should give / invoke the modal and whatever you need to pass to the modal, you can do it after you can get it to invoke.
Let me know if you need futher help.
HS2
Hi,
If you don`t mind can you send code for me. last two weeks iam tring to implemented same functionlities. but i can`t please help me.
Hello aspireConsulting,
Thanks for your help and suggestion.
I have figured out my own solution and this one is definitely simpler.
All I have to do was to call the OnLoad method and call the same script code that I called on the OnClick method. The OnLoad registers/initilialize the modal to the LinkButton for the first time when the page loads up
The initial question that I posted is
https://es.infragistics.com/community/forums/f/ultimate-ui-for-windows-forms/11844/creating-a-background-image-on-the-fly-fitting-into-an-appointment#11844
And this gave me the solution with my modal but it caused the issue that I have listed above. But the full solution is using #11844 and using the OnLoad to have the modal loads the first time on the first click.
Hope this will help to all who experiences this same problem.
Happy Coding!
<asp:LinkButton runat="server" ID="myID" OnClientClick ="BLOCKED SCRIPTdoIt()"></asp:LinkButton>
As necesary, you may want to use OnClientClick='<%# "BLOCKED SCRIPTdoIt(" + Eval("column") +")" %>' to put values in the OnClientClient should there be data you want to pass.
But, given what you describe, using a regular server link, href, or an image button with a client side event might be better choices. You'll find otherwise the grid still trying to post even in the absence of an onclick event for the link button. (which is likely due to the link button itself).