I'm hoping someone can help me. I have searched the web for a suitable answer but haven't found one.
I have the following LinkButton in a GridView (GridView2) which is within an UpdatePanel set to UpdateMode='Conditional':
<ItemTemplate>
<asp:LinkButton ID="lblSCcomments" runat="server" Width="80"
Text='<%#Eval("ShortCode")%>' CommandName="hyperSC"
OnCommand="GridView2_Command"
CommandArgument='<%#Eval("ShortCode")%>'/>
</ItemTemplate>
with this code behind:
protected void GridView2_Command(object sender, CommandEventArgs e)
{
if (e.CommandName == "hyperSC")
{
string sc = e.CommandArgument.ToString();
lblShortCode.Text = sc;
Session["scode"] = sc;
Server.Transfer("~/MemberPages/reviews.aspx");
}
}
Unfortunately, when I click on the link the command is not firing. But this was working outside of the UpdatePanel. I don't need the Gridview to refresh, just need to populate the Session variable and lblShortCode Label with the selected row Shortcode and be redirected to another page.
You have to add OnRowCommand event in your GridView like <asp:GridView ID="GridView2" runat="server" OnRowCommand="GridView2_RowCommand"> and do you .CS code in this event:
protected void GridView2_RowCommand(object sender, CommandEventArgs e)
{
if (e.CommandName == "hyperSC")
{
string sc = e.CommandArgument.ToString();
lblShortCode.Text = sc;
Session["scode"] = sc;
Server.Transfer("~/MemberPages/reviews.aspx");
}
}
And remove the OnCommand event from LinkButton.
Related
I have a user control, I want to make if conditions in the ascx, and upon that call a function in the user control and return data from the method to be displayed as html in the ascx. Any ideas? I am still newbie to asp.
Just drop a literal onto your user control. Then in your code behind, it'll look something like this:
private void Page_Load(object sender, System.EventArgs e)
{
// Make your IF conditions here
MyFunction();
}
private void MyFunction()
{
string myHtml = "<div>My Html Code!</div>";
literal1.Text = myHtml;
}
That should render your HTML.
I use RPC calls to connect to mySql and bring text data from there.
My page is defined as split Layout.
my problem is that I don't know how to update the main layout with different text.
if i use the clear() method it will remove all the layout !
"p" is the splitLayout.
RPC:
rpcService.getChapterTxt(selectedBook,bookChapters[selectedBook],
new AsyncCallback<List<BibleTxt>>(){
public void onFailure(Throwable caught)
{
Window.alert("Failed getting Chapter");
}
public void onSuccess(List<BibleTxt> result)
{
int i = 0 ;
String verseText ="";
//Label verseLabel = new Label();
PPanel chapterPar = new PPanel();
HTML page= new HTML(verseText);
for(i=0;i<result.size();i++)
{
verseText = result.get(i).getVerseText();
//verseLabel.setText(verseText);
page.setText(page.getText() + verseText);
}
chapterPar.add(page);
//p.clear();
p.add(chapterPar); // adds the main layout
}
});
Why you don't reuse the text component changing its content text instead of continuously detaching/attaching elements to the widget hierarchy. That way should perform better and cause less problems.
I have a simple modal popup which can be closed by a button. On the page where modal is going to be displayed there is a placeholder with an id. When the page first loads i addOrReplace an empty Panel. Then, in response to proper action I swap this panel with the modal panel. Then I close the panel and swap it again with another empty panel. Everything works fine. But here's the strange thing - when I do this the second time, the modal panel opens normally, but when I press close it does not close even if it is replaced by the new empty panel and added to the target - but it worked before! When I press same button again, everything crashes not being able to find component for markup for the modal (but there should be no markup for it anymore!)
I have thought about it all day yet I still haven't found the reason for all this. Any help would be much appreciated.
private void swapToDummyPopupContainer() {
currentPopupContainer = new DummyPanel("popupContainer");
addOrReplace(currentPopupContainer);
}
private void swapToCreationPopupContainer(final FCalendarEvent event) {
EventCreationPopup popup = new EventCreationPopup("popupContainer", event) {
private static final long serialVersionUID = 965466080498078142L;
#Override
public void onDataSubmit(AjaxRequestTarget target) {
AvailabilityDTO model = getModel();
event.setTitle(model.getDescription());
pushNewEventToModel(model);
availabilityMapping.put(event.getId(), model);
FCalendarEventActions.addEvent(target, fcalendar, event);
swapToDummyPopupContainer();
target.add(currentPopupContainer);
}
#Override
public void onCancel(AjaxRequestTarget target) {
swapToDummyPopupContainer();
target.add(currentPopupContainer);
}
};
currentPopupContainer = popup;
addOrReplace(currentPopupContainer);
}
#Override
protected void onRangeSelection(AjaxRequestTarget target, Date startDate, Date endDate,
boolean isAllDay) {
final FCalendarEvent event = new FCalendarEvent();
swapToCreationPopupContainer(event);
target.add(currentPopupContainer);
}
As for the markup there's
<wicket:container wicket:id="popupContainer" />
in the parent panel and both panels to be swapped are defined like this
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
<wicket:panel>
</wicket:panel>
</html>
at the end of the modal markup (before closing tag) there is javascript, but I don't believe it has anything to do with it:
<script type="text/javascript">
var $modal = $('#eventCreationPopup');
$modal.modal('setting', {
selector : {
close : '',
approve : '',
deny : ''
}
});
$modal.modal("show");
</script>
You cannot attach an JavaScript event to
<wicket:container wicket:id="popupContainer" />
because wicket:container has no real tag in the final markup you generate by Wicket. setOutputMarkupPlaceholderTag(true) has no effect in this case.
Change it to the DIV tag:
<div wicket:id="popupContainer"></div>
I have created a Dialog with two buttons Yes, No, and then I have add action listener to them, my problem is that I want no button to hide the Dialog that I have created
the code is looks like:
dialog = new Dialog(title);
dialog.setDialogType(Dialog.TYPE_CONFIRMATION);
ta = new TextArea(text);
ta.getStyle().setBorder(Border.createEmpty());
ta.setEditable(false);
yesCommand = new Button("YES");
noCommand = new Button("NO");
yesCommand.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
LGBMainMidlet.getLGBMidlet().notifyDestroyed();
}
});
noCommand.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
Logger.Log("Bye Bye");
dialog = null;
System.gc();
}
});
dialog.addComponent(ta);
dialog.addComponent(yesCommand);
dialog.addComponent(noCommand);
dialog.show();
the code is not working for me, can anyone told me what is the problem?
B.N. I have used dialog.dispose(), but it exit the whole application
It is better to use
dialog.setTimeout(1000); the number show the time limit the dialog box wait in milliseconds. So by doing this you can exit the dialog form automatically.
Dialog.dispose() does not exit the whole application, it just closes the dialog.
If you have nothing in your application you might see nothing if you dispose the dialog.
I have a AspxGridView and when i double click to a row, it shows a modal window. What i want to do is, send one columns' value to a AspxLabel which is at ModalWindow. But i couldn't manage to do it, in gridview i use ClientSideEvents RowDblClick to get row value. Here is the code:
GridView:
<dxwgv:ASPxGridView ID="gw_Parameters" runat="server"
CssFilePath="~/App_Themes/Aqua/{0}/styles.css" CssPostfix="Aqua"
AutoGenerateColumns="False" ClientInstanceName="grid"
OnCustomDataCallback="gw_Parameters_CustomDataCallback">
<ClientSideEvents RowDblClick="function(s, e) {
grid.GetValuesOnCustomCallback(e.visibleIndex, ShowModalWindow())
}" />
Script:
function ShowModalWindow(val)
{
pcc_Question.Show();
lblCQuestionText.SetText(val);
}
And c#:
protected void gw_Parameters_CustomDataCallback(object sender, ASPxGridViewCustomDataCallbackEventArgs e)
{
int visibleIndex = Convert.ToInt32(e.Parameters);
string fieldName = string.Empty;
if (gw_Parameters.VisibleColumns[0] is GridViewCommandColumn)
fieldName = ((GridViewDataColumn)gw_Parameters.VisibleColumns[3]).FieldName;
else
fieldName = ((GridViewDataColumn)gw_Parameters.VisibleColumns[2]).FieldName;
e.Result = gw_Parameters.GetRowValues(visibleIndex, fieldName);
}
Thanks for the help,
Mehmet Şerif Tozlu
Your code looks correct and should work. I suggest that you set the breakpoint in the gw_Parameters_CustomDataCallback method and check the e.Result value. Also, according to your code, the lblCQuestionText is the ClientInstanceName property of the label residing in the PopupControl. Is it true?
Mehmet,
Try the results here which has several examples.